forked from git-ecosystem/git-credential-manager
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e914015
commit dba839c
Showing
1 changed file
with
168 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
name: .NET Tool Signing | ||
on: | ||
- push | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
prereqs: | ||
name: Prerequisites | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.version.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set version | ||
run: echo "version=$(cat VERSION | sed -E 's/.[0-9]+$//')" >> $GITHUB_OUTPUT | ||
id: version | ||
|
||
# ================================ | ||
# .NET Tool | ||
# ================================ | ||
dotnet-tool-payload-sign: | ||
name: Build .NET tool and Sign Payload | ||
runs-on: windows-latest | ||
needs: prereqs | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up .NET | ||
uses: actions/setup-dotnet@v3.2.0 | ||
with: | ||
dotnet-version: 7.0.x | ||
|
||
- name: Build .NET tool | ||
shell: bash | ||
run: | | ||
$GITHUB_WORKSPACE/src/shared/DotnetTool/layout.sh ` | ||
--configuration=Release | ||
- name: Log into Azure | ||
uses: azure/login@v1 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
||
- name: Sign payload files with Azure Code Signing | ||
uses: azure/azure-code-signing-action@v0.2.20 | ||
with: | ||
endpoint: https://wus2.codesigning.azure.net/ | ||
code-signing-account-name: git-fundamentals-signing | ||
certificate-profile-name: git-fundamentals-windows-signing | ||
files-folder: ${{ github.workspace }}\out\shared\DotnetTool\nupkg\Release | ||
files-folder-filter: exe,dll | ||
file-digest: SHA256 | ||
timestamp-rfc3161: http://timestamp.acs.microsoft.com | ||
timestamp-digest: SHA256 | ||
|
||
- name: Lay out signed payload, images, and symbols | ||
shell: bash | ||
run: | | ||
mkdir dotnet-tool-payload-sign | ||
rm -rf payload | ||
mv images payload.sym -t dotnet-tool-payload-sign | ||
unzip signed/payload.zip -d dotnet-tool-payload-sign | ||
- name: Upload signed payload | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dotnet-tool-payload-sign | ||
path: | | ||
dotnet-tool-payload-sign | ||
dotnet-tool-pack: | ||
name: Package .NET tool | ||
runs-on: ubuntu-latest | ||
needs: [ prereqs, dotnet-tool-payload-sign ] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download signed payload | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dotnet-tool-payload-sign | ||
path: signed | ||
|
||
- name: Set up .NET | ||
uses: actions/setup-dotnet@v3.2.0 | ||
with: | ||
dotnet-version: 7.0.x | ||
|
||
- name: Package tool | ||
run: | | ||
src/shared/DotnetTool/pack.sh --configuration=Release \ | ||
--version="${{ needs.prereqs.outputs.version }}" \ | ||
--publish-dir=$(pwd)/signed | ||
- name: Upload unsigned package | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: tmp.dotnet-tool-package-unsigned | ||
path: | | ||
out/shared/DotnetTool/nupkg/Release/*.nupkg | ||
dotnet-tool-sign: | ||
name: Sign .NET tool package | ||
# ESRP service requires signing to run on Windows | ||
runs-on: windows-latest | ||
environment: release | ||
needs: dotnet-tool-pack | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download unsigned package | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: tmp.dotnet-tool-package-unsigned | ||
path: nupkg | ||
|
||
- name: Zip unsigned package | ||
shell: pwsh | ||
run: | | ||
Compress-Archive -Path nupkg/*.nupkg nupkg/gcm-nupkg.zip | ||
cd nupkg | ||
Get-ChildItem -Exclude gcm-nupkg.zip | Remove-Item -Recurse -Force | ||
- name: Log into Azure | ||
uses: azure/login@v1 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
||
- name: Set up ESRP client | ||
shell: pwsh | ||
env: | ||
AZURE_VAULT: ${{ secrets.AZURE_VAULT }} | ||
AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }} | ||
AZURE_STORAGE_CONTAINER: ${{ secrets.AZURE_STORAGE_CONTAINER }} | ||
ESRP_TOOL: ${{ secrets.ESRP_TOOL }} | ||
AUTH_CERT: ${{ secrets.AZURE_VAULT_AUTH_CERT_NAME }} | ||
REQUEST_SIGNING_CERT: ${{ secrets.AZURE_VAULT_REQUEST_SIGNING_CERT_NAME }} | ||
run: | | ||
.github\set_up_esrp.ps1 | ||
- name: Sign package | ||
shell: pwsh | ||
env: | ||
AZURE_AAD_ID: ${{ secrets.AZURE_AAD_ID }} | ||
NUGET_KEY_CODE: ${{ secrets.NUGET_KEY_CODE }} | ||
NUGET_OPERATION_CODE: ${{ secrets.NUGET_OPERATION_CODE }} | ||
run: | | ||
python .github\run_esrp_signing.py nupkg $env:NUGET_KEY_CODE $env:NUGET_OPERATION_CODE | ||
- name: Unzip signed package | ||
shell: pwsh | ||
run: | | ||
Expand-Archive -LiteralPath signed\gcm-nupkg.zip -DestinationPath .\signed -Force | ||
Remove-Item signed\gcm-nupkg.zip -Force | ||
- name: Publish signed package | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dotnet-tool-sign | ||
path: signed/*.nupkg |