Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1#!/usr/bin/env nix-shell 2#!nix-shell -i bash -p coreutils curl jq git gnupg common-updater-scripts 3set -euo pipefail 4 5# Fetch latest release, GPG-verify the tag, update derivation 6 7scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd) 8nixpkgs=$(realpath "$scriptDir"/../../../..) 9 10oldVersion=$(nix-instantiate --eval -E "(import \"$nixpkgs\" { config = {}; overlays = []; }).electrs.version" | tr -d '"') 11version=$(curl -s --show-error "https://api.github.com/repos/romanz/electrs/releases/latest" | jq -r '.tag_name' | tail -c +2) 12 13if [[ $version == $oldVersion ]]; then 14 echo "Already at latest version $version" 15 exit 0 16fi 17echo "New version: $version" 18 19tmpdir=$(mktemp -d /tmp/electrs-verify-gpg.XXX) 20repo=$tmpdir/repo 21trap "rm -rf $tmpdir" EXIT 22 23git clone --depth 1 --branch v${version} -c advice.detachedHead=false https://github.com/romanz/electrs $repo 24git -C $repo checkout tags/v${version} 25 26export GNUPGHOME=$tmpdir 27echo 28echo "Fetching romanz's key" 29gpg --keyserver hkps://keys.openpgp.org --recv-keys 15c8c3574ae4f1e25f3f35c587cae5fa46917cbb 2> /dev/null 30echo 31echo "Verifying commit" 32git -C $repo verify-tag v${version} 33 34rm -rf $repo/.git 35hash=$(nix hash path $repo) 36 37(cd "$nixpkgs" && update-source-version electrs "$version" "$hash") 38sed -i 's|cargoHash = .*|cargoHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";|' "$scriptDir/default.nix" 39echo 40echo "electrs: $oldVersion -> $version"