Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / hy / hyprland / update.sh
blobc729705f6b1d0c7c49a9e8fceaeac1761e6e3f59
1 #!/usr/bin/env nix-shell
2 #! nix-shell -i bash -p common-updater-scripts fd jq
4 set -eou pipefail
6 latest_release="$(curl --silent 'https://api.github.com/repos/hyprwm/Hyprland/releases/latest')"
7 latest_tag="$(curl --silent 'https://api.github.com/repos/hyprwm/Hyprland/tags?per_page=1')"
8 commit_hash="$(jq -r '.[0].commit.sha' <<<"$latest_tag")"
9 latest_commit="$(curl --silent 'https://api.github.com/repos/hyprwm/Hyprland/commits/'"$commit_hash"'')"
10 commit_message="$(jq -r '.commit.message' <<<"$latest_commit")"
12 tag=$(jq -r '.tag_name' <<<"$latest_release")
13 # drop 'v' prefix
14 version="${tag#v}"
16 branch=$(jq -r '.target_commitish' <<<"$latest_release")
18 date=$(jq -r '.created_at' <<<"$latest_release")
19 # truncate time
20 date=${date%T*}
22 # update version; otherwise fail
23 update-source-version hyprland "$version" --ignore-same-hash
25 # find hyprland dir
26 files="$(fd --full-path /hyprland/ | head -1)"
27 dir="${files%/*}"
29 echo -e '{
30 "branch": "'"$branch"'",
31 "commit_hash": "'"$commit_hash"'",
32 "commit_message": "'"$commit_message"'",
33 "date": "'"$date"'",
34 "tag": "'"$tag"'"
35 }' >"$dir/info.json"