aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/data/fonts/iosevka/update-bin.sh
blob: a402f152d8a13f22cf28ae7f5d1c1af1d7f2367b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p curl jq

set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"

release=$(curl -s https://api.github.com/repos/be5invis/Iosevka/releases/latest)

oldVersion=$(nix-instantiate --eval -E 'with import ../../../.. {}; lib.getVersion iosevka-bin' | tr -d '"')
version=$(echo "$release" | jq -r .tag_name | tr -d v)

if test "$oldVersion" = "$version"; then
	echo "New version same as old version, nothing to do." >&2
	exit 0
fi

sed -i "s/$oldVersion/$version/" bin.nix

{
	echo '# This file was autogenerated. DO NOT EDIT!'
	echo '{'
	for asset in $(echo "$release" | jq -r '.assets[].name | select(startswith("ttc"))'); do
		printf '  %s = "%s";\n' \
			$(echo "$asset" | sed -r "s/^ttc-(.*)-$version.zip$/\1/") \
			$(nix-prefetch-url "https://github.com/be5invis/Iosevka/releases/download/v$version/$asset")
	done
	echo '}'
} >variants.nix