Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ jobs:
key_file="$(mktemp)"
trap 'rm -f "${key_file}"' EXIT

if [[ "${GPG_PRIVATE_KEY}" == *"-----BEGIN PGP PRIVATE KEY BLOCK-----"* ]]; then
printf '%s' "${GPG_PRIVATE_KEY}" | sed 's/\\n/\n/g' > "${key_file}"
normalized_key="$(printf '%s' "${GPG_PRIVATE_KEY}" | sed 's/\\n/\n/g')"

if [[ "${normalized_key}" == *"-----BEGIN PGP PRIVATE KEY BLOCK-----"* ]]; then
printf '%s' "${normalized_key}" > "${key_file}"
else
printf '%s' "${GPG_PRIVATE_KEY}" | base64 --decode > "${key_file}"
if ! printf '%s' "${normalized_key}" | base64 --decode > "${key_file}" 2>/dev/null; then
echo "::notice::GPG_PRIVATE_KEY is not valid base64-encoded. Using raw key format. If import fails, verify the secret contains a valid PGP private key block (armored format)."
printf '%s' "${normalized_key}" > "${key_file}"
fi
fi

gpg --batch --import "${key_file}"
Expand Down