Skip to content

Commit 2588d38

Browse files
committed
Fix GPG configuration issues in CI
- Remove existing gpg.conf before creating new one to avoid conflicts - Use simpler gpg.conf with only use-agent (pinentry-mode handled via command line) - Kill existing gpg-agent before starting fresh - Fix ownertrust fingerprint format: remove colons in addition to spaces - Add sleep after starting gpg-agent to ensure it's ready
1 parent 64f3bec commit 2588d38

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

.github/workflows/main.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,24 +256,32 @@ jobs:
256256
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
257257
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
258258
run: |
259-
# Install gnupg2 if not already available (includes gpg-preset-passphrase)
259+
# Install gnupg2 if not already available
260260
sudo apt-get update && sudo apt-get install -y gnupg2 || true
261261
262262
# Create GPG directory
263263
mkdir -p ~/.gnupg
264264
chmod 700 ~/.gnupg
265265
266+
# Remove any existing gpg.conf to avoid conflicts
267+
rm -f ~/.gnupg/gpg.conf
268+
266269
# Configure GPG for non-interactive use
267-
# Note: allow-loopback-pinentry is a gpg-agent option, not gpg.conf option
268-
echo "use-agent" > ~/.gnupg/gpg.conf
269-
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
270+
# pinentry-mode is a valid GPG option, but use simpler config
271+
cat > ~/.gnupg/gpg.conf <<EOF
272+
use-agent
273+
EOF
270274
271275
# Configure gpg-agent for loopback pinentry
272-
echo "allow-loopback-pinentry" > ~/.gnupg/gpg-agent.conf
276+
cat > ~/.gnupg/gpg-agent.conf <<EOF
277+
allow-loopback-pinentry
278+
EOF
273279
chmod 600 ~/.gnupg/gpg-agent.conf
274280
275-
# Start gpg-agent with loopback pinentry (ignore error if already running)
276-
gpg-agent --daemon --allow-loopback-pinentry 2>&1 || true
281+
# Kill any existing gpg-agent and start fresh with loopback pinentry
282+
gpgconf --kill gpg-agent 2>/dev/null || true
283+
gpg-agent --daemon --allow-loopback-pinentry > /dev/null 2>&1 || true
284+
sleep 1 # Give gpg-agent time to start
277285
278286
# Import the subkey
279287
# Write key to temp file (key data is okay, but passphrase never touches disk)
@@ -287,10 +295,10 @@ jobs:
287295
rm -f "$KEY_FILE"
288296
289297
# Trust the key (required for signing)
290-
# Format: fingerprint:trust-level: (fingerprint must be uppercase, no spaces)
298+
# Format: fingerprint:trust-level: (fingerprint must be uppercase, no spaces, no colons)
291299
# Use ultimate trust (6) for the subkey
292-
FINGERPRINT_UPPER=$(echo "$GPG_FINGERPRINT" | tr '[:lower:]' '[:upper:]' | tr -d ' ')
293-
echo "$FINGERPRINT_UPPER:6:" | gpg --import-ownertrust
300+
FINGERPRINT_UPPER=$(echo "$GPG_FINGERPRINT" | tr '[:lower:]' '[:upper:]' | tr -d ' ' | tr -d ':')
301+
echo "$FINGERPRINT_UPPER:6:" | gpg --batch --import-ownertrust
294302
295303
# Verify key is available
296304
gpg --list-secret-keys --keyid-format LONG

0 commit comments

Comments
 (0)