1#!/usr/bin/env -S nix shell nixpkgs#nix nixpkgs#curl nixpkgs#jq nixpkgs#prefetch-yarn-deps nixpkgs#nix-prefetch-github nixpkgs#nix-prefetch-git --command bash
2
3if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
4 echo "Regenerates packaging data for matrix-hookshot."
5 echo "Usage: $0 [git release tag]"
6 exit 1
7fi
8
9version="$1"
10
11set -euo pipefail
12
13if [ -z "$version" ]; then
14 version="$(curl "https://api.github.com/repos/matrix-org/matrix-hookshot/releases?per_page=1" | jq -r '.[0].tag_name')"
15fi
16
17src="https://raw.githubusercontent.com/matrix-org/matrix-hookshot/$version"
18src_hash=$(nix-prefetch-github matrix-org matrix-hookshot --rev ${version} | jq -r .hash)
19
20tmpdir=$(mktemp -d)
21trap 'rm -rf "$tmpdir"' EXIT
22
23pushd $tmpdir
24curl -O "$src/yarn.lock"
25yarn_hash=$(prefetch-yarn-deps yarn.lock)
26popd
27
28curl -O "$src/package.json"
29# There is no prefetcher for the cargo hash, but care should still be taken to update it
30cat > pin.json << EOF
31{
32 "version": "$version",
33 "srcHash": "$src_hash",
34 "yarnHash": "$yarn_hash",
35 "cargoHash": "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
36}
37EOF