Skip to content

Commit 21e364e

Browse files
authored
Enhance CI with signing job for artifacts
Added signing job to the CI workflow for artifacts.
1 parent d171030 commit 21e364e

1 file changed

Lines changed: 88 additions & 1 deletion

File tree

.github/workflows/dotnet.yml

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: windows-latest
1615

1716
steps:
@@ -29,3 +28,91 @@ jobs:
2928
run: dotnet build --no-restore
3029
- name: Test
3130
run: dotnet test --no-build --verbosity normal
31+
32+
- name: Upload signing file list
33+
uses: actions/upload-artifact@v3
34+
with:
35+
name: config
36+
path: config
37+
38+
- name: Upload build artifacts
39+
uses: actions/upload-artifact@v3
40+
with:
41+
name: BuildArtifacts
42+
path: src/Kerberos.NET/bin/Release/**/*.nupkg
43+
44+
sign:
45+
needs: build
46+
runs-on: windows-latest # Code signing must run on a Windows agent for Authenticode signing (dll/exe)
47+
if: ${{ github.ref == 'refs/heads/develop' }} # Only run this job on pushes to the develop branch
48+
permissions:
49+
id-token: write # Required for requesting the JWT
50+
51+
steps:
52+
53+
# Download signing configuration and artifacts
54+
- name: Download signing config
55+
uses: actions/download-artifact@v3
56+
with:
57+
name: config
58+
path: config
59+
60+
- name: Download build artifacts
61+
uses: actions/download-artifact@v3
62+
with:
63+
name: BuildArtifacts
64+
path: BuildArtifacts
65+
66+
# .NET is required on the agent for the tool to run
67+
- name: Setup .NET
68+
uses: actions/setup-dotnet@v3
69+
with:
70+
dotnet-version: '9.x'
71+
72+
# Install the code signing tool
73+
- name: Install Sign CLI tool
74+
run: dotnet tool install --tool-path . --prerelease sign
75+
76+
# Login to Azure using a ServicePrincipal configured to authenticate agaist a GitHub Action
77+
- name: 'Az CLI login'
78+
uses: azure/login@v1
79+
with:
80+
allow-no-subscriptions: true
81+
client-id: ${{ secrets.AZURE_CLIENT_ID }} # This does not need to be a secret and is just a placeholder
82+
tenant-id: ${{ secrets.AZURE_TENANT_ID }} # This does not need to be a secret and is just a placeholder
83+
84+
# Run the signing command
85+
- name: Sign Kerberos.NET artifacts
86+
shell: pwsh
87+
run: >
88+
.\sign code azure-key-vault `
89+
"**/*.nupkg" `
90+
--base-directory "$(Pipeline.Workspace)\BuildPackages" `
91+
--file-list "$(Pipeline.Workspace)\config\filelist.txt" `
92+
--publisher-name "Kerberos.NET" `
93+
--description "Kerberos.NET" `
94+
--description-url "https://github.com/dotnet/Kerberos.NET" `
95+
--azure-credential-type "azure-cli"
96+
--azure-key-vault-url "${{ secrets.KEY_VAULT_URL }}" # This does not need to be a secret and is just a placeholder
97+
--azure-key-vault-certificate "${{ secrets.KEY_VAULT_CERTIFICATE_ID }}" # This does not need to be a secret and is just a placeholder
98+
99+
- name: Sign Bruce artifacts
100+
shell: pwsh
101+
run: >
102+
.\sign code azure-key-vault `
103+
"**/*.nupkg" `
104+
--base-directory "$(Pipeline.Workspace)\drop" `
105+
--file-list "$(Pipeline.Workspace)\config\filelist.txt" `
106+
--publisher-name "Bruce" `
107+
--description "Command line client for Kerberos.NET" `
108+
--description-url "https://github.com/dotnet/Kerberos.NET" `
109+
--azure-credential-type "azure-cli"
110+
--azure-key-vault-url "${{ secrets.KEY_VAULT_URL }}" # This does not need to be a secret and is just a placeholder
111+
--azure-key-vault-certificate "${{ secrets.KEY_VAULT_CERTIFICATE_ID }}" # This does not need to be a secret and is just a placeholder
112+
113+
# Publish the signed packages
114+
- name: Upload build artifacts
115+
uses: actions/upload-artifact@v3
116+
with:
117+
name: SignedArtifacts
118+
path: BuildArtifacts

0 commit comments

Comments
 (0)