1717 steps :
1818 # Checkout the repository
1919 - name : Checkout Code
20- uses : actions/checkout@v3
20+ uses : actions/checkout@v4
21+ with :
22+ persist-credentials : false
2123
2224 # Read and Trim Version
2325 - name : Read and Trim Version
6870 env :
6971 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7072
73+ - name : Setup PowerShell module cache
74+ id : cacher
75+ uses : actions/cache@v3
76+ with :
77+ path : " ~/.local/share/powershell/Modules"
78+ key : ${{ runner.os }}-ModuleBuilder
79+
80+ - name : Install ModuleBuilder
81+ if : steps.cacher.outputs.cache-hit != 'true'
82+ shell : pwsh
83+ run : |
84+ Set-PSRepository PSGallery -InstallationPolicy Trusted
85+ Install-Module ModuleBuilder -AllowClobber -Force
86+
87+ - name : Build CIPPCore Module
88+ shell : pwsh
89+ run : |
90+ $ModulePath = Join-Path $env:GITHUB_WORKSPACE "Modules/CIPPCore"
91+ $OutputPath = Join-Path $env:GITHUB_WORKSPACE "Output"
92+
93+ Write-Host "Building module from: $ModulePath"
94+ Write-Host "Output directory: $OutputPath"
95+
96+ # Generate function permissions before replacing the source module
97+ $ToolsPath = Join-Path $env:GITHUB_WORKSPACE "Tools"
98+ $ScriptPath = Join-Path $ToolsPath "Build-FunctionPermissions.ps1"
99+ pwsh -File $ScriptPath -ModulePath $ModulePath
100+
101+ # Build the module using ModuleBuilder
102+ Build-Module -SourcePath $ModulePath -OutputDirectory $OutputPath -Verbose
103+
104+ # Replace the source module with the built module
105+ Remove-Item -Path $ModulePath -Recurse -Force
106+ Copy-Item -Path (Join-Path $OutputPath "CIPPCore") -Destination $ModulePath -Recurse -Force
107+
108+ Write-Host "Module built and replaced successfully"
109+
110+ # Clean up output directory
111+ Remove-Item -Path $OutputPath -Recurse -Force
112+
113+ - name : Build CippExtensions Module
114+ shell : pwsh
115+ run : |
116+ $ModulePath = Join-Path $env:GITHUB_WORKSPACE "Modules/CippExtensions"
117+ $OutputPath = Join-Path $env:GITHUB_WORKSPACE "Output"
118+
119+ Write-Host "Building module from: $ModulePath"
120+ Write-Host "Output directory: $OutputPath"
121+
122+ # Build the module using ModuleBuilder
123+ Build-Module -SourcePath $ModulePath -OutputDirectory $OutputPath -Verbose
124+
125+ # Replace the source module with the built module
126+ Remove-Item -Path $ModulePath -Recurse -Force
127+ Copy-Item -Path (Join-Path $OutputPath "CippExtensions") -Destination $ModulePath -Recurse -Force
128+
129+ Write-Host "Module built and replaced successfully"
130+
131+ # Clean up output directory
132+ Remove-Item -Path $OutputPath -Recurse -Force
133+
134+
71135 # Create ZIP File in a New Source Directory
72136 - name : Prepare and Zip Release Files
73137 if : env.tag_exists == 'false'
91155 container_name : cipp-api
92156 source_folder : src/releases/
93157 destination_folder : /
94- delete_if_exists : true
158+ delete_if_exists : true
0 commit comments