From 433c4238cc38295ebcf9247330bf2ab50e046c7d Mon Sep 17 00:00:00 2001 From: Aldo Borrero <82811+aldoborrero@users.noreply.github.com> Date: Tue, 13 Feb 2024 13:43:41 +0100 Subject: [PATCH] feat: add update.sh script to teku --- pkgs/teku/update.sh | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) mode change 100644 => 100755 pkgs/teku/update.sh diff --git a/pkgs/teku/update.sh b/pkgs/teku/update.sh old mode 100644 new mode 100755 index d31d4cbf..2629cd69 --- a/pkgs/teku/update.sh +++ b/pkgs/teku/update.sh @@ -1,7 +1,7 @@ #!/usr/bin/env nix-shell #!nix-shell -i bash -p curl jq nix sd -set -e +set -ex dirname="$(dirname "$0")" rootDir="$(git -C "$dirname" rev-parse --show-toplevel)" @@ -15,19 +15,13 @@ updateVersion() { updateHash() { local version=$1 local url="https://artifacts.consensys.net/public/${pname}/raw/names/${pname}.tar.gz/versions/${version}/${pname}-${version}.tar.gz" - - local output=$(nix store prefetch-file --json "$url") - local sriHash=$(echo "$output" | jq -r .hash) - - sd "\"hash\" = \"[a-zA-Z0-9\/+-=]*\";" "\"hash\" = \"$sriHash\";" "${dirname}/default.nix" + local sriHash=$(nix store prefetch-file --json "$url" | jq -r '.hash') + sd 'hash = "[a-zA-Z0-9/+-=]*";' "hash = \"$sriHash\";" "${dirname}/default.nix" } -currentVersion=$(nix show-derivation "${rootDir}#${pname}" | jq -r '.[].env.version') +currentVersion=$(nix derivation show "${rootDir}#${pname}" | jq -r '.[].env.version') latestVersion=$(curl -s "https://api.github.com/repos/ConsenSys/teku/releases/latest" | jq -r '.tag_name') -# Optionally strip leading 'v' if present in the tag name -latestVersion=${latestVersion#v} - if [[ "$currentVersion" == "$latestVersion" ]]; then echo "${pname} is up to date: ${currentVersion}" exit 0