about summary refs log tree commit diff
path: root/pkgs/test/check-by-name/update-pinned-tool.sh
blob: 7240bd597f13156504d1ae3083e2e2a2f955bb63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p jq curl

set -o pipefail -o errexit -o nounset

trace() { echo >&2 "$@"; }

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

repository=NixOS/nixpkgs-check-by-name
pin_file=$SCRIPT_DIR/pinned-version.txt

trace -n "Fetching latest release of $repository.. "
latestRelease=$(curl -sSfL \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/"$repository"/releases/latest)
latestVersion=$(jq .tag_name -r <<< "$latestRelease")
trace "$latestVersion"

trace "Updating $pin_file"
echo "$latestVersion" > "$pin_file"