|
33 | 33 | path: "~/.local/share/powershell/Modules" |
34 | 34 | key: ${{ runner.os }}-ModuleBuilder |
35 | 35 |
|
| 36 | + - name: Install ModuleBuilder |
| 37 | + if: steps.cacher.outputs.cache-hit != 'true' |
| 38 | + shell: pwsh |
| 39 | + run: | |
| 40 | + Set-PSRepository PSGallery -InstallationPolicy Trusted |
| 41 | + Install-Module ModuleBuilder -AllowClobber -Force |
| 42 | +
|
| 43 | + - name: Build CIPPCore Module |
| 44 | + shell: pwsh |
| 45 | + run: | |
| 46 | + $ModulePath = Join-Path $env:GITHUB_WORKSPACE "Modules/CIPPCore" |
| 47 | + $OutputPath = Join-Path $env:GITHUB_WORKSPACE "Output" |
| 48 | +
|
| 49 | + Write-Host "Building module from: $ModulePath" |
| 50 | + Write-Host "Output directory: $OutputPath" |
| 51 | +
|
| 52 | + # Generate function permissions before replacing the source module |
| 53 | + $ToolsPath = Join-Path $env:GITHUB_WORKSPACE "Tools" |
| 54 | + $ScriptPath = Join-Path $ToolsPath "Build-FunctionPermissions.ps1" |
| 55 | + pwsh -File $ScriptPath -ModulePath $ModulePath |
| 56 | +
|
| 57 | + # Build the module using ModuleBuilder |
| 58 | + Build-Module -SourcePath $ModulePath -OutputDirectory $OutputPath -Verbose |
| 59 | +
|
| 60 | + # Replace the source module with the built module |
| 61 | + Remove-Item -Path $ModulePath -Recurse -Force |
| 62 | + Copy-Item -Path (Join-Path $OutputPath "CIPPCore") -Destination $ModulePath -Recurse -Force |
| 63 | +
|
| 64 | + Write-Host "Module built and replaced successfully" |
| 65 | +
|
| 66 | + # Clean up output directory |
| 67 | + Remove-Item -Path $OutputPath -Recurse -Force |
| 68 | +
|
| 69 | + - name: Build CippExtensions Module |
| 70 | + shell: pwsh |
| 71 | + run: | |
| 72 | + $ModulePath = Join-Path $env:GITHUB_WORKSPACE "Modules/CippExtensions" |
| 73 | + $OutputPath = Join-Path $env:GITHUB_WORKSPACE "Output" |
| 74 | +
|
| 75 | + Write-Host "Building module from: $ModulePath" |
| 76 | + Write-Host "Output directory: $OutputPath" |
| 77 | +
|
| 78 | + # Build the module using ModuleBuilder |
| 79 | + Build-Module -SourcePath $ModulePath -OutputDirectory $OutputPath -Verbose |
| 80 | +
|
| 81 | + # Replace the source module with the built module |
| 82 | + Remove-Item -Path $ModulePath -Recurse -Force |
| 83 | + Copy-Item -Path (Join-Path $OutputPath "CippExtensions") -Destination $ModulePath -Recurse -Force |
| 84 | +
|
| 85 | + Write-Host "Module built and replaced successfully" |
| 86 | +
|
| 87 | + # Clean up output directory |
| 88 | + Remove-Item -Path $OutputPath -Recurse -Force |
| 89 | +
|
36 | 90 | - name: Login to Azure |
37 | 91 | uses: azure/login@v2 |
38 | 92 | with: |
|
0 commit comments