Skip to content

Commit 4e902d6

Browse files
committed
signing files update
1 parent ae3bbe5 commit 4e902d6

3 files changed

Lines changed: 88 additions & 0 deletions

File tree

.github/assets/release-assets-config.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@
5757
{
5858
"name": "SHA256SUMS",
5959
"description": "Checksums for all files"
60+
},
61+
{
62+
"name": "SHA256SUMS.gpgsig",
63+
"description": "GPG detached signature"
64+
},
65+
{
66+
"name": "SHA256SUMS.sig",
67+
"description": "Cosign signature"
68+
},
69+
{
70+
"name": "SHA256SUMS.pem",
71+
"description": "Cosign certificate"
6072
}
6173
]
6274
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Script to sign SHA256SUMS with GPG and Cosign
6+
# Usage: sign-checksums.sh <bin-directory>
7+
#
8+
# Environment variables:
9+
# GPG_FINGERPRINT - GPG key fingerprint for signing (required)
10+
#
11+
# Outputs:
12+
# SHA256SUMS.gpgsig - GPG detached signature
13+
# SHA256SUMS.sig - Cosign signature
14+
# SHA256SUMS.pem - Cosign certificate
15+
16+
function main {
17+
local -r bin_dir="${1:-bin}"
18+
19+
if [[ ! -d "$bin_dir" ]]; then
20+
echo "ERROR: Directory $bin_dir does not exist"
21+
exit 1
22+
fi
23+
24+
if [[ -z "${GPG_FINGERPRINT}" ]]; then
25+
echo "ERROR: GPG_FINGERPRINT environment variable is not set"
26+
exit 1
27+
fi
28+
29+
# Use pushd/popd to avoid side effects on caller's working directory
30+
pushd "$bin_dir" || exit 1
31+
32+
if [[ ! -f "SHA256SUMS" ]]; then
33+
echo "ERROR: SHA256SUMS file not found in $bin_dir"
34+
popd || exit 1
35+
exit 1
36+
fi
37+
38+
# GPG signing
39+
echo "Signing SHA256SUMS with GPG..."
40+
gpg --batch --yes -u "${GPG_FINGERPRINT}" \
41+
--output SHA256SUMS.gpgsig \
42+
--detach-sign SHA256SUMS
43+
44+
echo "GPG signature created: SHA256SUMS.gpgsig"
45+
46+
# Cosign signing (keyless OIDC)
47+
echo "Signing SHA256SUMS with Cosign..."
48+
cosign sign-blob SHA256SUMS \
49+
--oidc-issuer=https://token.actions.githubusercontent.com \
50+
--output-certificate=SHA256SUMS.pem \
51+
--output-signature=SHA256SUMS.sig \
52+
--yes
53+
54+
echo "Cosign signature created: SHA256SUMS.sig"
55+
echo "Cosign certificate created: SHA256SUMS.pem"
56+
57+
echo ""
58+
echo "All signatures generated successfully:"
59+
ls -la SHA256SUMS*
60+
61+
popd || exit 1
62+
}
63+
64+
main "$@"

.github/workflows/release.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ jobs:
7272
- name: Generate SHA256SUMS
7373
run: .github/scripts/release/generate-checksums.sh bin
7474

75+
- name: Import GPG key
76+
run: |
77+
echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode | gpg --import
78+
GPG_FINGERPRINT=$(gpg --list-secret-keys --keyid-format LONG | awk '/^sec/{sub(/.*\//, "", $2); print $2; exit}')
79+
echo "GPG_FINGERPRINT=${GPG_FINGERPRINT}" >> "${GITHUB_ENV}"
80+
81+
- name: Install Cosign
82+
uses: sigstore/cosign-installer@v3
83+
84+
- name: Sign SHA256SUMS
85+
run: .github/scripts/release/sign-checksums.sh bin
86+
7587
- name: Verify signatures before upload
7688
run: .github/scripts/release/verify-files.sh bin
7789

0 commit comments

Comments
 (0)