Add certificate registration steps #7
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: release-signed | |
on: | |
push: | |
branches: | |
- signed_release | |
permissions: | |
contents: read | |
env: | |
DOTNET_NOLOGO: 1 | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
DOTNET_GENERATE_ASPNET_CERTIFICATE: 0 | |
ContinuousIntegrationBuild: true | |
RestoreLockedMode: true | |
Configuration: Release | |
RepositoryBranch: '${{ github.ref_name }}' | |
RepositoryCommit: '${{ github.sha }}' | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: setup dotnet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
6 | |
7 | |
8 | |
9 | |
- name: restore | |
run: dotnet restore | |
- name: build | |
run: dotnet build --no-restore | |
- name: test | |
run: dotnet test --no-build --no-restore | |
- name: pack | |
run: dotnet pack --no-build --no-restore -o dist | |
- name: publish artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: VbaCompression_unsigned_packages | |
path: | | |
${{ github.workspace }}/dist | |
${{ github.workspace }}/src/Kavod.Vba.Compression/README.md | |
sign: | |
needs: build | |
environment: sign | |
runs-on: windows-2022 | |
permissions: | |
contents: read | |
id-token: write | |
attestations: write | |
steps: | |
- name: publish artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: VbaCompression_unsigned_packages | |
- name: azure login | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.TRUSTED_SIGNING_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: setup tools | |
run: | | |
dotnet tool install --global sign --version 0.9.1-beta.24529.1 | |
dotnet tool install --global Knapcode.CertificateExtractor --version 0.1.1 | |
- name: sign | |
run: > | |
sign code trusted-signing | |
**/*.nupkg | |
--base-directory "${{ github.workspace }}/dist" | |
--publisher-name "NetOffice" | |
--description "VbaCompression library" | |
--description-url "https://github.com/NetOfficeFw/VbaCompression" | |
--trusted-signing-endpoint "https://weu.codesigning.azure.net/" | |
--trusted-signing-account "OpenSourceSigning" | |
--trusted-signing-certificate-profile "JozefIzsoOpenSourceProfile" | |
- name: attestation | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-path: 'dist/*.nupkg' | |
show-summary: true | |
- name: extract certificate | |
shell: pwsh | |
run: | | |
dotnet tool install --global Knapcode.CertificateExtractor | |
$nupkg = Get-ChildItem -Filter dist\*.nupkg | Select-Object -First 1 | |
nuget-cert-extractor --file $nupkg --output dist --code-signing --author --leaf | |
- name: certificate summary | |
shell: pwsh | |
run: | | |
& { | |
echo '# NuGet Certificate Registration' | |
echo '' | |
echo 'To publish packages to NuGet.org, you must register the trusted signing certificate.' | |
echo '' | |
echo 'Download the `certificate` artifact, extract the `.cer` file and register it' | |
echo 'in your NuGet account at <https://www.nuget.org/account>' | |
} | Out-File -FilePath $env:GITHUB_STEP_SUMMARY | |
- name: publish certificate | |
uses: actions/upload-artifact@v4 | |
with: | |
name: certificate | |
path: | | |
${{ github.workspace }}/dist/*.cer | |
- name: publish artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: VbaCompression_signed_packages | |
path: | | |
${{ github.workspace }}/dist | |
${{ github.workspace }}/src/Kavod.Vba.Compression/README.md |