Fix source location test when set to absent #70
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| defaults: | |
| run: | |
| shell: pwsh | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| release: | |
| types: [ published ] | |
| jobs: | |
| Build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Upload module | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: module | |
| path: ./src/ | |
| Test: | |
| needs: Build | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Install PSWSMan | |
| if: runner.os != 'Windows' | |
| run: Install-PSResource PSWSMan -TrustRepository; Install-WSMan | |
| - name: Install PSDesiredStateConfiguration | |
| run: Install-PSResource PSDesiredStateConfiguration -TrustRepository | |
| - name: Install AnyPackage.PSResourceGet | |
| run: Install-PSResource AnyPackage.PSResourceGet -TrustRepository | |
| - name: Download module | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: module | |
| path: AnyPackageDsc | |
| - name: Move module | |
| run: | | |
| if ($IsWindows) { | |
| $path = "$HOME\Documents\PowerShell\Modules" | |
| } else { | |
| $path = "$HOME/.local/share/powershell/Modules" | |
| } | |
| Move-Item AnyPackageDsc $path | |
| - name: Test with Pester | |
| run: | | |
| $ht = Import-PowerShellDataFile PesterSettings.psd1 | |
| $config = New-PesterConfiguration $ht | |
| Invoke-Pester -Configuration $config | |
| Sign: | |
| needs: Test | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Download module | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: module | |
| path: module | |
| - name: Import certificate | |
| env: | |
| CERTIFICATE_BASE64: ${{ secrets.CERTIFICATE_BASE64 }} | |
| CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }} | |
| CERTIFICATE_PASSWORD_KEY_BASE64: ${{ secrets.CERTIFICATE_PASSWORD_KEY_BASE64 }} | |
| run: | | |
| [convert]::FromBase64String($env:CERTIFICATE_BASE64) | Set-Content -Path cert.pfx -AsByteStream | |
| $key = [convert]::FromBase64String($env:CERTIFICATE_PASSWORD_KEY_BASE64) | |
| $password = ConvertTo-SecureString $env:CERTIFICATE_PASSWORD -Key $key | |
| Import-PfxCertificate cert.pfx -Password $password -CertStoreLocation Cert:\CurrentUser\My | |
| - name: Sign files | |
| run: | | |
| $config = Import-PowerShellDataFile SignSettings.psd1 | |
| $config['Certificate'] = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert | |
| Set-Location .\module | |
| Set-AuthenticodeSignature @config | |
| - name: Create and sign catalog file | |
| run: | | |
| $config = Import-PowerShellDataFile SignSettings.psd1 | |
| $config['FilePath'] = 'AnyPackageDsc.cat' | |
| $config['Certificate'] = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert | |
| Set-Location .\module | |
| New-FileCatalog $config['FilePath'] -CatalogVersion 2 | |
| Set-AuthenticodeSignature @config | |
| - name: Upload module | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: module-signed | |
| path: ./module/ | |
| Publish: | |
| needs: Sign | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download module | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: module-signed | |
| path: '~/.local/share/powershell/Modules/AnyPackageDsc' | |
| - name: Install AnyPackage | |
| run: Install-PSResource AnyPackage -TrustRepository | |
| - name: Publish Module | |
| env: | |
| NUGET_KEY: ${{ secrets.NUGET_KEY }} | |
| run: | | |
| $module = Get-Module AnyPackageDsc -ListAvailable | |
| Publish-PSResource $module.ModuleBase -ApiKey $env:NUGET_KEY |