about summary refs log tree commit diff
path: root/pkgs/applications/misc/1password-gui/update.sh
blob: aab589fd37ea5eefd6a3e4acf524f535a81b391f (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p jq
#shellcheck shell=bash

CURRENT_HASH=""

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

    if [[ "$OS" == "linux" ]]; then
        if [[ "$ARCH" == "x86_64" ]]; then
            EXT="x64.tar.gz"
        else
            EXT="arm64.tar.gz"
        fi
        URL="https://downloads.1password.com/${OS}/tar/${CHANNEL}/${ARCH}/1password-${VERSION}.${EXT}"
    else
        EXT="$ARCH.zip"
        URL="https://downloads.1password.com/${OS}/1Password-${VERSION}-${EXT}"
    fi

    CURRENT_HASH=$(nix store prefetch-file "$URL" --json | jq -r '.hash')

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

if [[ -z "$STABLE_VER" ]]; then
    echo "No 'STABLE_VER' environment variable provided, skipping"
else
    print_hash "linux" "stable" "x86_64" "$STABLE_VER"
    print_hash "linux" "stable" "aarch64" "$STABLE_VER"
    print_hash "mac" "stable" "x86_64" "$STABLE_VER"
    print_hash "mac" "stable" "aarch64" "$STABLE_VER"
fi

if [[ -z "$BETA_VER" ]]; then
    echo "No 'BETA_VER' environment variable provided, skipping"
else
    print_hash "linux" "beta" "x86_64" "$BETA_VER"
    print_hash "linux" "beta" "aarch64" "$BETA_VER"
    print_hash "mac" "beta" "x86_64" "$BETA_VER"
    print_hash "mac" "beta" "aarch64" "$BETA_VER"
fi