depot/third_party/nixpkgs/pkgs/by-name/ch/chrysalis/update.sh
Default email 98eb3e9ef5 Project import generated by Copybara.
GitOrigin-RevId: 00d80d13810dbfea8ab4ed1009b09100cca86ba8
2024-07-01 15:47:52 +00:00

16 lines
652 B
Bash
Executable file

#! /usr/bin/env nix-shell
#! nix-shell -i bash --pure -p curl cacert jq
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
DRV_DIR="$PWD"
relinfo=$(curl -sL 'https://api.github.com/repos/keyboardio/chrysalis/releases' | jq 'map(select(.prerelease == false)) | max_by(.tag_name)')
newver=$(echo "$relinfo" | jq --raw-output '.tag_name' | sed 's|^v||')
hashurl=$(echo "$relinfo" | jq --raw-output '.assets[] | select(.name == "latest-linux.yml").browser_download_url')
newhash=$(curl -sL "$hashurl" | grep -Po '^sha512: \K.*')
sed -i package.nix \
-e "/^ version =/ s|\".*\"|\"$newver\"|" \
-e "/sha512-/ s|\".*\"|\"sha512-$newhash\"|" \