about summary refs log tree commit diff
path: root/overlays/mjolnir-package/update.sh
blob: 1ada42981c184bdc276c97796eefb44dfaed20df (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
29
30
31
32
33
34
35
36
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix curl jq prefetch-yarn-deps nix-prefetch-github

if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
  echo "Regenerates packaging data for mjolnir."
  echo "Usage: $0 [git release tag]"
  exit 1
fi

version=$1

set -euo pipefail

if [ -z "$version" ]; then
  version=$(curl "https://api.github.com/repos/matrix-org/mjolnir/releases/latest" | jq -r '.tag_name')
fi

src="https://raw.githubusercontent.com/matrix-org/mjolnir/$version"
src_hash=$(nix-prefetch-github matrix-org mjolnir --rev ${version} | jq -r .sha256)

tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT

pushd $tmpdir
curl -O "$src/yarn.lock"
yarn_hash=$(prefetch-yarn-deps yarn.lock)
popd

curl -O "$src/package.json"
cat > pin.json << EOF
{
  "version": "$version",
  "srcHash": "$src_hash",
  "yarnHash": "$yarn_hash"
}
EOF