coder: add updateScript
This commit is contained in:
parent
e87abac607
commit
841e60c6c5
|
@ -86,4 +86,8 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
|||
mainProgram = "coder";
|
||||
maintainers = with lib.maintainers; [ ghuntley urandom ];
|
||||
};
|
||||
|
||||
passthru = {
|
||||
updateScript = ./update.sh;
|
||||
};
|
||||
})
|
||||
|
|
31
pkgs/development/tools/coder/update.sh
Executable file
31
pkgs/development/tools/coder/update.sh
Executable file
|
@ -0,0 +1,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
|
Loading…
Reference in New Issue
Block a user