52aaa8388e
Previously, when used to update `nix-bitcoin-release`, the error wasn't displayed but instead written to `nix-bitcoin-release`. Also, show curl error messages.
43 lines
1.2 KiB
Plaintext
Executable File
43 lines
1.2 KiB
Plaintext
Executable File
#!/usr/bin/env nix-shell
|
|
#!nix-shell -i bash -p bash coreutils curl jq gnupg
|
|
set -euo pipefail
|
|
|
|
scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd)
|
|
|
|
repo=fort-nix/nix-bitcoin
|
|
if [[ ! -v version ]]; then
|
|
version=$(curl -s --show-error "https://api.github.com/repos/$repo/releases/latest" | jq -r '.tag_name' | tail -c +2)
|
|
fi
|
|
|
|
TMPDIR=$(mktemp -d)
|
|
trap "rm -rf $TMPDIR" EXIT
|
|
|
|
GPG_HOME=$TMPDIR/gpg-home
|
|
mkdir -p -m 700 "$GPG_HOME"
|
|
|
|
# Import key
|
|
gpg --homedir $GPG_HOME --import "$scriptDir/key-jonasnick.bin" &> /dev/null
|
|
# Verify key fingerprint
|
|
gpg --homedir $GPG_HOME --list-keys 36C71A37C9D988BDE82508D9B1A70E4F8DCD0366 > /dev/null
|
|
|
|
# Fetch nar-hash of release
|
|
cd $TMPDIR
|
|
baseUrl=https://github.com/$repo/releases/download/v$version
|
|
curl -s --show-error -L -O $baseUrl/nar-hash.txt
|
|
curl -s --show-error -L -O $baseUrl/nar-hash.txt.asc
|
|
|
|
# Verify signature for nar-hash
|
|
gpg --homedir $GPG_HOME --verify nar-hash.txt.asc &> /dev/null || {
|
|
>&2 echo "Error: Signature verification failed. Please open an issue in the project repository."
|
|
exit 1
|
|
}
|
|
|
|
>&2 echo "Fetched and verified release $version"
|
|
|
|
cat <<EOF
|
|
builtins.fetchTarball {
|
|
url = "https://github.com/$repo/archive/v$version.tar.gz";
|
|
sha256 = "$(cat nar-hash.txt)";
|
|
}
|
|
EOF
|