Skip to content

Commit a1a2edf

Browse files
committed
Fix GPG signing: preset passphrase in gpg-agent and use --use-agent flag
1 parent a3a2921 commit a1a2edf

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,16 @@ jobs:
303303
# Verify key is available
304304
gpg --list-secret-keys --keyid-format LONG
305305
306+
# Preset passphrase in gpg-agent for non-interactive signing
307+
# This allows GoReleaser to sign without prompting for passphrase
308+
KEYGRIP=$(gpg --list-secret-keys --with-keygrip --keyid-format LONG "$FINGERPRINT_UPPER" | grep -A1 "^sec" | tail -1 | awk '{print $3}')
309+
if [ -n "$KEYGRIP" ]; then
310+
echo "$GPG_PASSPHRASE" | gpg-preset-passphrase --preset "$KEYGRIP"
311+
echo "✓ Passphrase preset in gpg-agent for keygrip: $KEYGRIP"
312+
else
313+
echo "⚠ Warning: Could not find keygrip for fingerprint $FINGERPRINT_UPPER"
314+
fi
315+
306316
# Test signing capability (GoReleaser will test this anyway, but verify key is importable)
307317
# Note: We skip actual signing test here since --passphrase-fd consumes stdin
308318
# GoReleaser uses --passphrase flag directly, which works differently

.goreleaser.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ signs:
4242
- id: checksum
4343
artifacts: checksum
4444
args:
45-
# if you are using this is a GitHub action or some other automated pipeline, you
46-
# need to pass the batch flag to indicate its not interactive.
45+
# Use gpg-agent with preset passphrase (set in GitHub Actions workflow)
4746
- "--batch"
4847
- "--pinentry-mode"
4948
- "loopback"
50-
- "--passphrase"
51-
- "{{ .Env.GPG_PASSPHRASE }}"
49+
- "--use-agent"
5250
- "--local-user"
5351
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
5452
- "--output"
@@ -61,8 +59,7 @@ signs:
6159
- "--batch"
6260
- "--pinentry-mode"
6361
- "loopback"
64-
- "--passphrase"
65-
- "{{ .Env.GPG_PASSPHRASE }}"
62+
- "--use-agent"
6663
- "--local-user"
6764
- "{{ .Env.GPG_FINGERPRINT }}"
6865
- "--output"

0 commit comments

Comments
 (0)