Skip to content

Commit 2675196

Browse files
vdyeldennington
authored andcommitted
release: add signing step for .deb package
- sign using Azure-stored certificates & client - sign on Windows agent via python script - job skipped if credentials for accessing certificate aren't present Co-authored-by: Lessley Dennington <ldennington@github.com>
1 parent 7c62bfa commit 2675196

1 file changed

Lines changed: 72 additions & 2 deletions

File tree

‎.github/workflows/build-git-installers.yml‎

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
tags:
66
- 'v[0-9]*vfs*' # matches "v<number><any characters>vfs<any characters>"
77

8+
permissions:
9+
id-token: write # required for Azure login via OIDC
10+
811
env:
912
DO_WIN_CODESIGN: ${{ secrets.WIN_CODESIGN_CERT_SECRET_NAME != '' && secrets.WIN_CODESIGN_PASS_SECRET_NAME != '' }}
1013
DO_WIN_GPGSIGN: ${{ secrets.WIN_GPG_KEYGRIP_SECRET_NAME != '' && secrets.WIN_GPG_PRIVATE_SECRET_NAME != '' && secrets.WIN_GPG_PASSPHRASE_SECRET_NAME != '' }}
@@ -541,7 +544,7 @@ jobs:
541544
git/.github/macos-installer/*.pkg
542545
# End build and sign Mac OSX installers
543546

544-
# Build unsigned Ubuntu package
547+
# Build and sign Debian package
545548
create-linux-unsigned-artifacts:
546549
runs-on: ubuntu-latest
547550
container:
@@ -636,10 +639,77 @@ jobs:
636639
# Move Debian package for later artifact upload
637640
mv "$PKGNAME.deb" "$GITHUB_WORKSPACE"
638641
642+
- name: Upload artifacts
643+
uses: actions/upload-artifact@v4
644+
with:
645+
name: linux-unsigned-artifacts
646+
path: |
647+
*.deb
648+
649+
create-linux-artifacts:
650+
runs-on: ubuntu-latest
651+
needs: [prereqs, create-linux-unsigned-artifacts]
652+
environment: release
653+
steps:
654+
- name: Log into Azure
655+
uses: azure/login@v2
656+
with:
657+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
658+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
659+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
660+
661+
- name: Check out repository (for akv-secret Action)
662+
uses: actions/checkout@v4
663+
with:
664+
path: git
665+
666+
- name: Download GPG secrets
667+
id: gpg-secrets
668+
uses: ./git/.github/actions/akv-secret
669+
with:
670+
vault: ${{ secrets.AZURE_VAULT }}
671+
secrets: |
672+
${{ secrets.LINUX_GPG_KEYGRIP_SECRET_NAME }} > $output:keygrip
673+
${{ secrets.LINUX_GPG_PRIVATE_SECRET_NAME }} base64> $output:private-key
674+
${{ secrets.LINUX_GPG_PASSPHRASE_SECRET_NAME }} > $output:passphrase
675+
676+
- name: Prepare for GPG signing
677+
run: |
678+
# Install debsigs
679+
sudo apt-get install -y debsigs
680+
681+
# Stop using SHA-1 for the signature. For details, see
682+
# https://gitlab.com/debsigs/debsigs/-/commit/75c6c8f96e6cdc33bca9c5f32195b68ff35bc32f
683+
# which seems to have made it to have made it into debsigs v0.2.1, but Ubuntu 24.04 is
684+
# stuck with v1.19.
685+
mkdir -p patched-debsigs &&
686+
sed 's/, "--openpgp"//' </usr/bin/debsigs >patched-debsigs/debsigs &&
687+
chmod a+x patched-debsigs/debsigs &&
688+
echo "$PWD/patched-debsigs" >>$GITHUB_PATH
689+
690+
# Import GPG key
691+
echo -n '${{ steps.gpg-secrets.outputs.private-key }}' | gpg --import --no-tty --batch --yes
692+
693+
# Configure GPG
694+
echo "allow-preset-passphrase" > ~/.gnupg/gpg-agent.conf
695+
gpg-connect-agent RELOADAGENT /bye
696+
/usr/lib/gnupg2/gpg-preset-passphrase --preset '${{ steps.gpg-secrets.outputs.keygrip }}' <<<'${{ steps.gpg-secrets.outputs.passphrase }}'
697+
698+
- name: Download artifacts
699+
uses: actions/download-artifact@v4
700+
with:
701+
name: linux-unsigned-artifacts
702+
703+
- name: Sign Debian package
704+
run: |
705+
# Sign Debian package
706+
version="${{ needs.prereqs.outputs.tag_version }}"
707+
debsigs --sign=origin --verify --check microsoft-git_"$version".deb
708+
639709
- name: Upload artifacts
640710
uses: actions/upload-artifact@v4
641711
with:
642712
name: linux-artifacts
643713
path: |
644714
*.deb
645-
# End build unsigned Debian package
715+
# End build and sign Debian package

0 commit comments

Comments
 (0)