depot/third_party/nixpkgs/pkgs/by-name/ke/keycastr/update.sh
Default email 159e378cbb Project import generated by Copybara.
GitOrigin-RevId: c04d5652cfa9742b1d519688f65d1bbccea9eb7e
2024-09-19 17:19:46 +03:00

20 lines
763 B
Bash
Executable file

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq gnused
set -euo pipefail
cd "$(dirname "$0")" || exit 1
# Grab latest release version
LATEST_VER="$(curl --fail -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/keycastr/keycastr/releases/latest" | jq -r '.tag_name' | sed 's/^v//')"
CURRENT_VER="$(grep -oP 'version = "\K[^"]+' package.nix)"
if [[ "$LATEST_VER" == "$CURRENT_VER" ]]; then
echo "keycastr is up-to-date"
exit 0
fi
HASH="$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url --type sha256 "https://github.com/keycastr/keycastr/releases/download/v${LATEST_VER}/KeyCastr.app.zip")")"
sed -i "s#hash = \".*\"#hash = \"$HASH\"#g" package.nix
sed -i "s#version = \".*\";#version = \"$LATEST_VER\";#g" package.nix