Skip to content

Commit

Permalink
feat: add update.sh script to teku
Browse files Browse the repository at this point in the history
  • Loading branch information
aldoborrero committed Feb 13, 2024
1 parent e5851a2 commit 433c423
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions pkgs/teku/update.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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)"
Expand All @@ -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
Expand Down

0 comments on commit 433c423

Please sign in to comment.