updated module #3
Workflow file for this run
This file contains 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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: Build and publish module | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- '**' | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: windows-latest | |
env: | |
MODULE_NAME: SpfAnalyzer | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore "$env:GITHUB_WORKSPACE\DnsApiLib" | |
- name: Build | |
run: dotnet build "$env:GITHUB_WORKSPACE\DnsApiLib" --no-restore | |
- name: Install AzureSignTool | |
run: dotnet tool install --global AzureSignTool | |
- name: Sign files | |
shell: pwsh | |
run: | | |
$files = Get-ChildItem "$env:GITHUB_WORKSPACE\Module\$env:MODULE_NAME" -File -Recurse -Include *.ps1, *.ps1xml, *.psd1, *.psm1, *.pssc, *.psrc, *.cdxml, *.dll | |
try { | |
foreach ($file in $files) { | |
azuresigntool sign ` | |
-kvu ${{ vars.CODESIGNING_KEYVAULTURI }} ` | |
-kvi ${{ vars.TENANTINTEGRATION_CLIENTID }} ` | |
-kvt ${{ vars.TENANTINTEGRATION_TENANTID }} ` | |
-kvs ${{ secrets.TENANTINTEGRATION_CLIENTSECRET }} ` | |
-kvc ${{ vars.CODESIGNING_CERTNAME }} ` | |
-tr 'http://timestamp.digicert.com' ` | |
-v "$($file.FullName)" | |
} | |
} | |
catch { | |
Write-Host "Error: $($_.Exception)" | |
throw | |
} | |
Write-Host "Signed files summary:" | |
Get-AuthenticodeSignature -FilePath $files | |
- name: Publish | |
#Publish to PS Gallery | |
shell: pwsh | |
if: ${{ github.event_name != 'workflow_dispatch' }} | |
env: | |
SECRET: ${{ secrets.GC_PSGALLERY_APIKEY }} | |
run: | | |
write-host "Publishing from: $env:GITHUB_WORKSPACE\Module\$env:MODULE_NAME" | |
try | |
{ | |
$env:PSModulePath = "$env:PSModulePath;$env:GITHUB_WORKSPACE\Module" | |
"PSModulePath: $env:PSModulePath" | |
Publish-Module -Path "$env:GITHUB_WORKSPACE\Module\$env:MODULE_NAME" -NuGetApiKey "$env:SECRET" | |
} | |
catch | |
{ | |
Write-Host "Error: $($_.Exception)" | |
throw | |
} | |