diff options
Diffstat (limited to 'pkgs/by-name/hy/hyprland/update.sh')
-rwxr-xr-x | pkgs/by-name/hy/hyprland/update.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pkgs/by-name/hy/hyprland/update.sh b/pkgs/by-name/hy/hyprland/update.sh new file mode 100755 index 0000000000000..c729705f6b1d0 --- /dev/null +++ b/pkgs/by-name/hy/hyprland/update.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env nix-shell +#! nix-shell -i bash -p common-updater-scripts fd jq + +set -eou pipefail + +latest_release="$(curl --silent 'https://api.github.com/repos/hyprwm/Hyprland/releases/latest')" +latest_tag="$(curl --silent 'https://api.github.com/repos/hyprwm/Hyprland/tags?per_page=1')" +commit_hash="$(jq -r '.[0].commit.sha' <<<"$latest_tag")" +latest_commit="$(curl --silent 'https://api.github.com/repos/hyprwm/Hyprland/commits/'"$commit_hash"'')" +commit_message="$(jq -r '.commit.message' <<<"$latest_commit")" + +tag=$(jq -r '.tag_name' <<<"$latest_release") +# drop 'v' prefix +version="${tag#v}" + +branch=$(jq -r '.target_commitish' <<<"$latest_release") + +date=$(jq -r '.created_at' <<<"$latest_release") +# truncate time +date=${date%T*} + +# update version; otherwise fail +update-source-version hyprland "$version" --ignore-same-hash + +# find hyprland dir +files="$(fd --full-path /hyprland/ | head -1)" +dir="${files%/*}" + +echo -e '{ + "branch": "'"$branch"'", + "commit_hash": "'"$commit_hash"'", + "commit_message": "'"$commit_message"'", + "date": "'"$date"'", + "tag": "'"$tag"'" +}' >"$dir/info.json" |