about summary refs log tree commit diff
path: root/pkgs/development/tools/fermyon-spin/update.sh
blob: 9d00621f1c3723ae97033954bdcf32d5a6a92bbc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p jq
#shellcheck shell=bash

CURRENT_HASH=""

print_hash() {
    OS="$1"
    ARCH="$2"
    VERSION="$3"

    URL="https://github.com/fermyon/spin/releases/download/v${VERSION}/spin-v${VERSION}-${OS}-${ARCH}.tar.gz"
    echo
    CURRENT_HASH=$(nix store prefetch-file "$URL" --json | jq -r '.hash')

    echo "${ARCH}-${OS}: $CURRENT_HASH"
}

if [[ -z "$VER" && -n "$1" ]]; then
    VER="$1"
fi

if [[ -z "$VER" ]]; then
    echo "No 'VER' environment variable provided, skipping"
else
    print_hash "linux"  "amd64"   "$VER"
    print_hash "linux"  "aarch64" "$VER"
    print_hash "macos" "amd64"   "$VER"
    print_hash "macos" "aarch64" "$VER"
fi