blob: a7ce3da93256a65847a94d8527dd2202f03adf48 (
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 curl jq common-updater-scripts
set -eu -o pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
LATEST_TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --silent https://api.github.com/repos/coder/coder/releases/latest | jq -r '.tag_name')
LATEST_VERSION=$(echo ${LATEST_TAG} | sed 's/^v//')
# change version number
sed -e "s/version =.*;/version = \"$LATEST_VERSION\";/g" \
-i ./default.nix
# Define the platforms
declare -A ARCHS=(["x86_64-linux"]="linux_amd64.tar.gz"
["aarch64-linux"]="linux_arm64.tar.gz"
["x86_64-darwin"]="darwin_amd64.zip"
["aarch64-darwin"]="darwin_arm64.zip")
# Update hashes for each architecture
for ARCH in "${!ARCHS[@]}"; do
URL="https://github.com/coder/coder/releases/download/v${LATEST_VERSION}/coder_${LATEST_VERSION}_${ARCHS[$ARCH]}"
echo "Fetching hash for $ARCH..."
# Fetch the new hash using nix-prefetch-url
NEW_HASH=$(nix-prefetch-url --type sha256 $URL)
# Update the Nix file with the new hash
sed -i "s|${ARCH} = \"sha256-.*\";|${ARCH} = \"sha256-${NEW_HASH}\";|" ./default.nix
done
|