1#!/usr/bin/env nix-shell
2#!nix-shell -i bash -p cacert jq git moreutils nix nix-prefetch-github
3# shellcheck shell=bash
4
5set -euo pipefail
6cd "$(dirname "${BASH_SOURCE[0]}")"
7
8repo=duckdb
9owner=duckdb
10
11msg() {
12 echo "$*" >&2
13}
14
15json_get() {
16 jq -r "$1" < ./versions.json
17}
18
19json_set() {
20 jq --arg x "$2" "$1 = \$x" < ./versions.json | sponge 'versions.json'
21}
22
23get_latest() {
24 gh release --repo "${owner}/${repo}" list \
25 --exclude-pre-releases \
26 --limit 1 \
27 --json tagName \
28 --jq '.[].tagName'
29}
30
31tag="$(get_latest | sed 's/^v//g')"
32
33json=$(nix-prefetch-github "${owner}" "${repo}" --rev "v${tag}")
34
35json_set ".version" "${tag}"
36json_set ".rev" "$(jq -r '.rev' <<< "${json}")"
37json_set ".hash" "$(jq -r '.hash' <<< "${json}")"