depot/pkgs/servers/matrix-appservice-discord/update.sh
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

42 lines
917 B
Bash
Executable file

#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../../../ -i bash -p nix curl jq prefetch-yarn-deps nix-prefetch-github
ORG="matrix-org"
PROJ="matrix-appservice-discord"
if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
echo "Regenerates packaging data for $PROJ."
echo "Usage: $0 [git release tag]"
exit 1
fi
tag="$1"
set -euo pipefail
if [ -z "$tag" ]; then
tag="$(
curl "https://api.github.com/repos/$ORG/$PROJ/releases?per_page=1" |
jq -r '.[0].tag_name'
)"
fi
src="https://raw.githubusercontent.com/$ORG/$PROJ/$tag"
src_hash=$(nix-prefetch-github $ORG $PROJ --rev ${tag} | jq -r .hash)
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
pushd $tmpdir
curl -O "$src/yarn.lock"
yarn_sha256=$(prefetch-yarn-deps yarn.lock)
popd
curl -O "$src/package.json"
cat > pin.json << EOF
{
"version": "$(echo $tag | grep -P '(\d|\.)+' -o)",
"srcHash": "$src_hash",
"yarnSha256": "$yarn_sha256"
}
EOF