Skip to content

Commit 27d7636

Browse files
committed
release: update Linux to use GPG signing
Update the Linux component of the release workflow to use GPG signing instead of ESRP.
1 parent 5562307 commit 27d7636

File tree

1 file changed

+54
-67
lines changed

1 file changed

+54
-67
lines changed

.github/workflows/release.yml

Lines changed: 54 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,11 @@ jobs:
360360
# ================================
361361
# Linux
362362
# ================================
363-
linux-build:
364-
name: Build Linux
363+
create-linux-artifacts:
364+
name: Create Linux Artifacts
365365
runs-on: ubuntu-latest
366+
environment: release
367+
needs: prereqs
366368
steps:
367369
- uses: actions/checkout@v4
368370

@@ -371,78 +373,68 @@ jobs:
371373
with:
372374
dotnet-version: 7.0.x
373375

374-
- name: Install dependencies
375-
run: dotnet restore
376-
377376
- name: Build
378377
run: dotnet build --configuration=LinuxRelease
379378

380-
- name: Lay out
379+
- name: Run Linux unit tests
381380
run: |
382-
mkdir -p linux-build/deb linux-build/tar
383-
mv out/linux/Packaging.Linux/Release/deb/*.deb linux-build/deb
384-
mv out/linux/Packaging.Linux/Release/tar/*.tar.gz linux-build/tar
381+
dotnet test --configuration=LinuxRelease
385382
386-
- name: Upload artifacts
387-
uses: actions/upload-artifact@v3
383+
- name: Log into Azure
384+
uses: azure/login@v1
388385
with:
389-
name: linux-build
390-
path: |
391-
linux-build
386+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
387+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
388+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
392389

393-
linux-sign:
394-
name: Sign Linux tarball and Debian package
395-
needs: linux-build
396-
# ESRP service requires signing to run on Windows
397-
runs-on: windows-latest
398-
environment: release
399-
steps:
400-
- uses: actions/checkout@v4
390+
- name: Prepare for GPG signing
391+
env:
392+
AZURE_VAULT: ${{ secrets.AZURE_VAULT }}
393+
GPG_KEY_SECRET_NAME: ${{ secrets.GPG_KEY_SECRET_NAME }}
394+
GPG_PASSPHRASE_SECRET_NAME: ${{ secrets.GPG_PASSPHRASE_SECRET_NAME }}
395+
GPG_KEYGRIP_SECRET_NAME: ${{ secrets.GPG_KEYGRIP_SECRET_NAME }}
396+
run: |
397+
# Install debsigs
398+
sudo apt install debsigs
401399
402-
- name: Download artifacts
403-
uses: actions/download-artifact@v3
404-
with:
405-
name: linux-build
400+
# Download GPG key, passphrase, and keygrip from Azure Key Vault
401+
key=$(az keyvault secret show --name $GPG_KEY_SECRET_NAME --vault-name $AZURE_VAULT --query "value")
402+
passphrase=$(az keyvault secret show --name $GPG_PASSPHRASE_SECRET_NAME --vault-name $AZURE_VAULT --query "value")
403+
keygrip=$(az keyvault secret show --name $GPG_KEYGRIP_SECRET_NAME --vault-name $AZURE_VAULT --query "value")
406404
407-
- name: Remove symbols
408-
run: |
409-
rm tar/*symbols*
405+
# Remove quotes from downloaded values
406+
key=$(sed -e 's/^"//' -e 's/"$//' <<<"$key")
407+
passphrase=$(sed -e 's/^"//' -e 's/"$//' <<<"$passphrase")
408+
keygrip=$(sed -e 's/^"//' -e 's/"$//' <<<"$keygrip")
410409
411-
- uses: azure/login@v1
412-
with:
413-
creds: ${{ secrets.AZURE_CREDENTIALS }}
410+
# Import GPG key
411+
echo "$key" | base64 -d | gpg --import --no-tty --batch --yes
414412
415-
- name: Set up ESRP client
416-
shell: pwsh
417-
env:
418-
AZURE_VAULT: ${{ secrets.AZURE_VAULT }}
419-
AUTH_CERT: ${{ secrets.AZURE_VAULT_AUTH_CERT_NAME }}
420-
REQUEST_SIGNING_CERT: ${{ secrets.AZURE_VAULT_REQUEST_SIGNING_CERT_NAME }}
421-
run: |
422-
.github\set_up_esrp.ps1
413+
# Configure GPG
414+
echo "allow-preset-passphrase" > ~/.gnupg/gpg-agent.conf
415+
gpg-connect-agent RELOADAGENT /bye
416+
/usr/lib/gnupg2/gpg-preset-passphrase --preset "$keygrip" <<<"$passphrase"
423417
424-
- name: Run ESRP client
425-
shell: pwsh
426-
env:
427-
AZURE_AAD_ID: ${{ secrets.AZURE_AAD_ID }}
428-
LINUX_KEY_CODE: ${{ secrets.LINUX_KEY_CODE }}
429-
LINUX_OP_CODE: ${{ secrets.LINUX_OPERATION_CODE }}
418+
- name: Sign Debian package and tarball
430419
run: |
431-
python .github/run_esrp_signing.py deb $env:LINUX_KEY_CODE $env:LINUX_OP_CODE
432-
python .github/run_esrp_signing.py tar $env:LINUX_KEY_CODE $env:LINUX_OP_CODE
420+
# Sign Debian package
421+
version=${{ needs.prereqs.outputs.version }}
422+
mv out/linux/Packaging.Linux/Release/deb/gcm-linux_amd64.$version.deb .
423+
debsigs --sign=origin --verify --check gcm-linux_amd64.$version.deb
433424
434-
- name: Re-name tarball signature file
435-
shell: bash
436-
run: |
437-
signaturepath=$(find signed/*.tar.gz)
438-
mv "$signaturepath" "${signaturepath%.tar.gz}.asc"
425+
# Generate tarball signature file
426+
mv -v out/linux/Packaging.Linux/Release/tar/* .
427+
gpg --batch --yes --armor --output gcm-linux_amd64.$version.tar.gz.asc \
428+
--detach-sig gcm-linux_amd64.$version.tar.gz
439429
440-
- name: Upload signed tarball and Debian package
430+
- name: Upload artifacts
441431
uses: actions/upload-artifact@v3
442432
with:
443-
name: linux-sign
433+
name: linux-artifacts
444434
path: |
445-
signed
435+
./*.deb
436+
./*.asc
437+
./*.tar.gz
446438
447439
# ================================
448440
# .NET Tool
@@ -628,13 +620,9 @@ jobs:
628620
matrix:
629621
component:
630622
- os: ubuntu-latest
631-
artifact: linux-sign
632-
command: git-credential-manager
633-
description: debian
634-
- os: ubuntu-latest
635-
artifact: linux-build
623+
artifact: linux-artifacts
636624
command: git-credential-manager
637-
description: tarball
625+
description: linux
638626
- os: macos-latest
639627
artifact: osx-x64-sign
640628
command: git-credential-manager
@@ -652,7 +640,7 @@ jobs:
652640
command: git-credential-manager
653641
description: dotnet-tool
654642
runs-on: ${{ matrix.component.os }}
655-
needs: [ osx-sign, win-sign, linux-sign, dotnet-tool-sign ]
643+
needs: [ osx-sign, win-sign, create-linux-artifacts, dotnet-tool-sign ]
656644
steps:
657645
- uses: actions/checkout@v4
658646

@@ -672,14 +660,14 @@ jobs:
672660
}
673661
674662
- name: Install Linux (Debian package)
675-
if: contains(matrix.component.description, 'debian')
663+
if: contains(matrix.component.description, 'linux')
676664
run: |
677665
debpath=$(find ./*.deb)
678666
sudo apt install $debpath
679667
"${{ matrix.component.command }}" configure
680668
681669
- name: Install Linux (tarball)
682-
if: contains(matrix.component.description, 'tarball')
670+
if: contains(matrix.component.description, 'linux')
683671
run: |
684672
# Ensure we find only the source tarball, not the symbols
685673
tarpath=$(find ./tar -name '*[[:digit:]].tar.gz')
@@ -797,8 +785,7 @@ jobs:
797785
uploadDirectoryToRelease('osx-payload-and-symbols'),
798786
799787
// Upload Linux artifacts
800-
uploadDirectoryToRelease('linux-build/tar'),
801-
uploadDirectoryToRelease('linux-sign'),
788+
uploadDirectoryToRelease('linux-artifacts'),
802789
803790
// Upload .NET tool package
804791
uploadDirectoryToRelease('dotnet-tool-sign'),

0 commit comments

Comments
 (0)