Skip to content

Commit 79f3031

Browse files
authored
fix(release): sign checksums with explicit GPG key in isolated keyring (#958)
* fix(release): sign checksums with explicit GPG key in isolated keyring The self-hosted release runner is persistent (not ephemeral), so the shared ~/.gnupg default keyring can end up in a state where gpg can't resolve an unambiguous default signing key, failing with "no default secret key: No public key". Import the key into a job-scoped GNUPGHOME and have goreleaser sign with the imported key's fingerprint explicitly instead of relying on gpg's default-key guess. * fix(ci): write proper KEY=VALUE to GITHUB_ENV for GNUPGHOME echo "$GNUPGHOME" >> "$GITHUB_ENV" wrote just the value with no key, which GitHub's env-file parser rejects ("Invalid format"). Test run against v0.1.30 caught this before it could hit a real release. * ci(release): disable actions/setup-go cache on the self-hosted runner GOCACHE/GOMODCACHE already persist on this runner's disk between runs since it's a long-lived machine, not ephemeral. Uploading/ downloading GitHub's remote Actions cache on top of that just adds several minutes of upload time for a multi-GB cache with no benefit.
1 parent 29fcb60 commit 79f3031

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎.github/workflows/goreleaser-self-hosted-test.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ jobs:
2525
with:
2626
go-version-file: 'go.mod'
2727
check-latest: true
28-
cache: true
28+
cache: false
2929
- name: Import GPG Key
3030
run: |
31+
export GNUPGHOME="$RUNNER_TEMP/gnupg"
32+
mkdir -m 700 -p "$GNUPGHOME"
33+
echo "GNUPGHOME=$GNUPGHOME" >> "$GITHUB_ENV"
3134
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import --no-tty --batch
3235
gpg --list-secret-keys
36+
fingerprint=$(gpg --list-secret-keys --with-colons | awk -F: '/^fpr:/ { print $10; exit }')
37+
echo "GPG_FINGERPRINT=$fingerprint" >> "$GITHUB_ENV"
3338
- name: install quill
3439
run: |
3540
curl -sSfL https://get.anchore.io/quill | sh -s -- -b "$RUNNER_TEMP/bin"

‎.github/workflows/goreleaser.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ jobs:
2424
with:
2525
go-version-file: 'go.mod'
2626
check-latest: true
27-
cache: true
27+
cache: false
2828
- name: Import GPG Key
2929
run: |
30+
export GNUPGHOME="$RUNNER_TEMP/gnupg"
31+
mkdir -m 700 -p "$GNUPGHOME"
32+
echo "GNUPGHOME=$GNUPGHOME" >> "$GITHUB_ENV"
3033
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import --no-tty --batch
3134
gpg --list-secret-keys
35+
fingerprint=$(gpg --list-secret-keys --with-colons | awk -F: '/^fpr:/ { print $10; exit }')
36+
echo "GPG_FINGERPRINT=$fingerprint" >> "$GITHUB_ENV"
3237
- name: install quill
3338
run: |
3439
curl -sSfL https://get.anchore.io/quill | sh -s -- -b "$RUNNER_TEMP/bin"

‎.goreleaser.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ project_name: onctl
33

44
signs:
55
- artifacts: checksum
6+
args:
7+
- "--batch"
8+
- "-u"
9+
- "{{ .Env.GPG_FINGERPRINT }}"
10+
- "--output"
11+
- "${signature}"
12+
- "--detach-sign"
13+
- "${artifact}"
614

715
before:
816
hooks:

0 commit comments

Comments
 (0)
⌂ 换网址