Sign 2026.x release downloads with minisign #417
No files matched your search
@@ -302,6 +302,7 @@ jobs:
|
||||
REPO: ${{ github.repository }}
|
||||
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
MINISIGN_SECRET_KEY: ${{ secrets.MINISIGN_SECRET_KEY }}
|
||||
steps:
|
||||
- name: take the binaries out of the image
|
||||
run: |
|
||||
@@ -319,6 +320,22 @@ jobs:
|
||||
done
|
||||
sha256sum inbuxa-linux-*.tar.gz > SHA256SUMS
|
||||
cat SHA256SUMS
|
||||
# Sign SHA256SUMS with the suite's minisign key, so a download can be
|
||||
# verified against the public key the docs publish. No key (as on a
|
||||
# fork, or before the key is added) leaves the release unsigned.
|
||||
- name: sign SHA256SUMS with minisign
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "${MINISIGN_SECRET_KEY:-}" ]; then
|
||||
echo "::warning::MINISIGN_SECRET_KEY is not set; this release will be unsigned"
|
||||
exit 0
|
||||
fi
|
||||
apk add --no-cache -q minisign
|
||||
umask 077
|
||||
key="$(mktemp)"; printf '%s\n' "$MINISIGN_SECRET_KEY" > "$key"
|
||||
minisign -S -s "$key" -m /out/SHA256SUMS -t "inbuxa $TAG"
|
||||
rm -f "$key"
|
||||
echo "signed /out/SHA256SUMS -> /out/SHA256SUMS.minisig"
|
||||
- name: attach them to the release
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -335,7 +352,10 @@ jobs:
|
||||
rel = get(f"/releases/tags/{tag}")
|
||||
assets = {a["name"]: a["id"] for a in get(f"/releases/{rel['id']}/assets")}
|
||||
|
||||
for path in ["/out/inbuxa-linux-amd64.tar.gz", "/out/inbuxa-linux-arm64.tar.gz", "/out/SHA256SUMS"]:
|
||||
for path in ["/out/inbuxa-linux-amd64.tar.gz", "/out/inbuxa-linux-arm64.tar.gz",
|
||||
"/out/SHA256SUMS", "/out/SHA256SUMS.minisig"]:
|
||||
if not pathlib.Path(path).exists():
|
||||
continue # SHA256SUMS.minisig is absent only on an unsigned release
|
||||
name = os.path.basename(path)
|
||||
# A re-run of a tag replaces its assets rather than leaving two
|
||||
# files with the same name and different contents.
|
||||
|
||||
@@ -386,6 +386,25 @@ jobs:
|
||||
done
|
||||
sha256sum inbuxa-linux-*.tar.gz > SHA256SUMS
|
||||
cat SHA256SUMS
|
||||
# Sign SHA256SUMS with the suite's minisign key, so a download can be
|
||||
# verified against the public key the docs publish, as Gitea's
|
||||
# publish.yml does when it builds. No key (as on a fork, or before the
|
||||
# key is added) leaves the release unsigned.
|
||||
- name: sign SHA256SUMS with minisign
|
||||
env:
|
||||
MINISIGN_SECRET_KEY: ${{ secrets.MINISIGN_SECRET_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "${MINISIGN_SECRET_KEY:-}" ]; then
|
||||
echo "::warning::MINISIGN_SECRET_KEY is not set; this release will be unsigned"
|
||||
exit 0
|
||||
fi
|
||||
sudo apt-get -qq update >/dev/null && sudo apt-get -qq install -y --no-install-recommends minisign >/dev/null
|
||||
umask 077
|
||||
key="$(mktemp)"; printf '%s\n' "$MINISIGN_SECRET_KEY" > "$key"
|
||||
minisign -S -s "$key" -m out/SHA256SUMS -t "inbuxa $TAG"
|
||||
rm -f "$key"
|
||||
echo "signed out/SHA256SUMS -> out/SHA256SUMS.minisig"
|
||||
# A re-run of a tag replaces its assets rather than leaving two files
|
||||
# with the same name and different contents.
|
||||
#
|
||||
@@ -400,7 +419,9 @@ jobs:
|
||||
retry=(--retry 5 --retry-all-errors --retry-delay 15)
|
||||
rel="$(curl -fsS "${retry[@]}" -H "$auth" "$api/releases/tags/$TAG" | jq -r .id)"
|
||||
assets="$(curl -fsS "${retry[@]}" -H "$auth" "$api/releases/$rel/assets")"
|
||||
for f in out/inbuxa-linux-amd64.tar.gz out/inbuxa-linux-arm64.tar.gz out/SHA256SUMS; do
|
||||
for f in out/inbuxa-linux-amd64.tar.gz out/inbuxa-linux-arm64.tar.gz out/SHA256SUMS \
|
||||
out/SHA256SUMS.minisig; do
|
||||
[ -e "$f" ] || continue # SHA256SUMS.minisig is absent only on an unsigned release
|
||||
name="$(basename "$f")"
|
||||
old="$(jq -r --arg n "$name" '.[] | select(.name == $n) | .id' <<<"$assets")"
|
||||
for id in $old; do curl -fsS "${retry[@]}" -o /dev/null -X DELETE -H "$auth" "$api/releases/$rel/assets/$id"; done
|
||||
|
||||
Reference in new issue
Block a user