diff options
| author | mtg0001 <106211915+mtg0001@users.noreply.github.com> | 2026-08-04 10:18:01 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-04 10:18:01 -0300 |
| commit | f6c5b813075cae4228d241a3567e70b210504749 (patch) | |
| tree | 8d408438f3579a6a170be4d04cc68d33ab292782 /scripts/make-release-checksums.sh | |
| parent | 530f91910a4eceb6705d1212fa0e3ebe8418c6a3 (diff) | |
Add release verification tooling (#108)
Co-authored-by: Gilcimar Duarte <ti@gpm.infra>
Diffstat (limited to 'scripts/make-release-checksums.sh')
| -rwxr-xr-x | scripts/make-release-checksums.sh | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/scripts/make-release-checksums.sh b/scripts/make-release-checksums.sh new file mode 100755 index 0000000..5b29e2d --- /dev/null +++ b/scripts/make-release-checksums.sh | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | set -euo pipefail | ||
| 3 | |||
| 4 | sign=0 | ||
| 5 | key="" | ||
| 6 | |||
| 7 | usage() { | ||
| 8 | cat <<'EOF' | ||
| 9 | Usage: scripts/make-release-checksums.sh [--sign] [--local-user KEYID] | ||
| 10 | |||
| 11 | Creates SHA256SUMS for release assets in the current directory: | ||
| 12 | Bitflash-*-windows.zip | ||
| 13 | Bitflash-*-x86_64.AppImage | ||
| 14 | bitflash-node-*-x86_64 | ||
| 15 | |||
| 16 | With --sign, also creates SHA256SUMS.asc as a detached ASCII-armored GPG | ||
| 17 | signature. Upload both files with the release assets. | ||
| 18 | EOF | ||
| 19 | } | ||
| 20 | |||
| 21 | while [ "$#" -gt 0 ]; do | ||
| 22 | case "$1" in | ||
| 23 | --sign) sign=1 ;; | ||
| 24 | --local-user) | ||
| 25 | [ "$#" -ge 2 ] || { echo "--local-user needs a key id" >&2; exit 2; } | ||
| 26 | key="$2" | ||
| 27 | shift | ||
| 28 | ;; | ||
| 29 | -h|--help) usage; exit 0 ;; | ||
| 30 | *) echo "unknown option: $1" >&2; usage >&2; exit 2 ;; | ||
| 31 | esac | ||
| 32 | shift | ||
| 33 | done | ||
| 34 | |||
| 35 | if command -v sha256sum >/dev/null 2>&1; then | ||
| 36 | sha_cmd=(sha256sum) | ||
| 37 | elif command -v shasum >/dev/null 2>&1; then | ||
| 38 | sha_cmd=(shasum -a 256) | ||
| 39 | else | ||
| 40 | echo "missing required command: sha256sum or shasum" >&2 | ||
| 41 | exit 1 | ||
| 42 | fi | ||
| 43 | |||
| 44 | assets=() | ||
| 45 | for pattern in \ | ||
| 46 | "Bitflash-*-windows.zip" \ | ||
| 47 | "Bitflash-*-x86_64.AppImage" \ | ||
| 48 | "bitflash-node-*-x86_64" | ||
| 49 | do | ||
| 50 | for file in $pattern; do | ||
| 51 | [ -e "$file" ] || continue | ||
| 52 | assets+=("$file") | ||
| 53 | done | ||
| 54 | done | ||
| 55 | |||
| 56 | if [ "${#assets[@]}" -eq 0 ]; then | ||
| 57 | echo "no release assets found in $(pwd)" >&2 | ||
| 58 | exit 1 | ||
| 59 | fi | ||
| 60 | |||
| 61 | printf '%s\n' "${assets[@]}" | LC_ALL=C sort | while IFS= read -r file; do | ||
| 62 | "${sha_cmd[@]}" "$file" | ||
| 63 | done > SHA256SUMS | ||
| 64 | |||
| 65 | echo "Wrote SHA256SUMS" | ||
| 66 | |||
| 67 | if [ "$sign" -eq 1 ]; then | ||
| 68 | if ! command -v gpg >/dev/null 2>&1; then | ||
| 69 | echo "missing required command: gpg" >&2 | ||
| 70 | exit 1 | ||
| 71 | fi | ||
| 72 | gpg_args=(--armor --detach-sign --output SHA256SUMS.asc) | ||
| 73 | if [ -n "$key" ]; then | ||
| 74 | gpg_args+=(--local-user "$key") | ||
| 75 | fi | ||
| 76 | gpg "${gpg_args[@]}" SHA256SUMS | ||
| 77 | echo "Wrote SHA256SUMS.asc" | ||
| 78 | fi | ||