mastodon: 4.3.1 -> 4.3.2 (#361487)
[NixPkgs.git] / pkgs / by-name / ya / yandex-music / update.sh
blobc60b8cdf9a2d1a16eeeec4786bd91065187c11f2
1 #!/usr/bin/env nix-shell
2 #! nix-shell -i bash -p common-updater-scripts fd jq
4 set -eou pipefail
6 OWNER="cucumber-sp"
7 REPO="yandex-music-linux"
8 URL="https://api.github.com/repos/$OWNER/$REPO"
9 RAW="https://raw.githubusercontent.com/$OWNER/$REPO"
11 latest_release="$(curl --silent "$URL/releases/latest")"
12 latest_tag="$(curl --silent "$URL/tags?per_page=1")"
13 commit_hash="$(jq -r '.[0].commit.sha' <<<"$latest_tag")"
14 tag=$(jq -r '.tag_name' <<<"$latest_release")
15 # drop 'v' prefix
16 version="${tag#v}"
18 date=$(jq -r '.created_at' <<<"$latest_release")
19 # truncate time
20 date=${date%T*}
22 # update version; otherwise fail
23 update-source-version yandex-music "$version" --ignore-same-hash
25 # set yandex-music dir
26 dir="pkgs/by-name/ya/yandex-music"
28 # download and save new version of 'exe' file
29 ym_info=$(curl --silent "$RAW/$commit_hash/utility/version_info.json" |\
30 jq '.ym')
32 exe_name="$(jq -r '.exe_name' <<<"$ym_info")"
33 exe_link="$(jq -r '.exe_link' <<<"$ym_info")"
34 exe_sha256="$(jq -r '.exe_sha256' <<<"$ym_info")"
35 exe_hash="$(nix-hash --to-sri --type sha256 "$exe_sha256")"
37 jq '.' > "$dir/ym_info.json" <<- EOJSON ||\
38 echo "Please run the script in the root of the Nixpkgs repo"
40 "version": "$version",
41 "exe_name": "$exe_name",
42 "exe_link": "$exe_link",
43 "exe_hash": "$exe_hash"
45 EOJSON