nixpkgs/pkgs/applications/editors/cudatext/update.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
1.4 KiB
Bash
Raw Normal View History

2021-12-12 15:20:57 +01:00
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnused jq nix-prefetch moreutils
set -euo pipefail
cd "$(dirname "$0")"
2022-06-15 10:49:18 +02:00
nixpkgs="$(git rev-parse --show-toplevel)"
oldVersion=$(nix-instantiate --eval -E "(import \"$nixpkgs\" { config = {}; overlays = []; }).cudatext.version" | tr -d '"')
2021-12-12 15:20:57 +01:00
version=$(curl -s https://api.github.com/repos/Alexey-T/CudaText/releases/latest | jq -r '.tag_name')
2022-06-15 10:49:18 +02:00
if [[ $version == $oldVersion ]]; then
echo "Already at latest version $version"
exit 0
fi
echo "New version: $version"
2021-12-12 15:20:57 +01:00
url="https://github.com/Alexey-T/CudaText/archive/refs/tags/${version}.tar.gz"
hash=$(nix-prefetch-url --quiet --unpack --type sha256 $url)
sriHash=$(nix hash to-sri --type sha256 $hash)
sed -i "s#version = \".*\"#version = \"$version\"#" default.nix
2022-08-28 11:07:50 +02:00
sed -i "s#hash = \".*\"#hash = \"$sriHash\"#" default.nix
2021-12-12 15:20:57 +01:00
while IFS=$'\t' read repo owner rev; do
latest=$(curl -s https://api.github.com/repos/${owner}/${repo}/releases/latest | jq -r '.tag_name')
if [ "$latest" != "$rev" ]; then
url="https://github.com/${owner}/${repo}/archive/refs/tags/${latest}.tar.gz"
hash=$(nix-prefetch-url --quiet --unpack --type sha256 $url)
sriHash=$(nix hash to-sri --type sha256 $hash)
2022-08-28 11:07:50 +02:00
jq ".\"${repo}\".rev = \"${latest}\" | .\"${repo}\".hash = \"${sriHash}\"" deps.json | sponge deps.json
2021-12-12 15:20:57 +01:00
fi
done <<< $(jq -r 'to_entries[]|[.key,.value.owner,.value.rev]|@tsv' deps.json)