diff --git a/hyprpm.toml b/hyprpm.toml index 6441551..e1ce9df 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -15,7 +15,8 @@ commit_pins = [ ["f044e4c9514ec89c4c1fc8a523ca90b8cb907fb7", "070ca398300bf5b9e1a636ca057882c0312c228d"], # CMonitor* -> PHLMONITOR ["a425fbebe4cf4238e48a42f724ef2208959d66cf", "a86ed5581498186ed31241c0c246629ef771d1e6"], # v0.45.0 ["500d2a3580388afc8b620b0a3624147faa34f98b", "cb929099477407116031010905ce439db771dd62"], # v0.45.1 - ["12f9a0d0b93f691d4d9923716557154d74777b0a", "47f6fea6d297dbee8a9c5dea905783bde506fe79"], # v0.45.2 +["12f9a0d0b93f691d4d9923716557154d74777b0a", "cb929099477407116031010905ce439db771dd62"], # v0.45.2 + ## DO NOT EDIT THIS LINE: for auto pin script ## ] [hyprgrass] diff --git a/scripts/ci/latest-hyprland-tag b/scripts/ci/latest-hyprland-tag new file mode 100755 index 0000000..6bd1c91 --- /dev/null +++ b/scripts/ci/latest-hyprland-tag @@ -0,0 +1,9 @@ +#!/bin/sh + +## Usage +## ----- +## Prints the tag name of the latest Hyprland release + +# if anyone knows jq help me rewrite this +gh release list --repo hyprwm/Hyprland --json tagName,isLatest | \ + nix eval --impure --raw --expr 'with builtins; (head (filter (x: x.isLatest) (fromJSON (readFile /dev/stdin)))).tagName' diff --git a/scripts/ci/pin-latest-hyprland b/scripts/ci/pin-latest-hyprland new file mode 100755 index 0000000..8da91d8 --- /dev/null +++ b/scripts/ci/pin-latest-hyprland @@ -0,0 +1,57 @@ +#!/bin/sh + +set -eu + +usage() { + echoerr "Usage:" + echoerr "" + echoerr " pin-latest-hyprland [HYPRGRASS_REV]" + echoerr "" + echoerr "Pins the latest hyprland release to HYPRGRASS_REV (default HEAD) in hyprpm.toml." + echoerr "Does nothing if a pin on the hyprland release already exists." +} + +HYPRGRASS_REV=${1:-HEAD} + +echoerr() { + echo $@ >&2 +} + +findHyprpmPin() { + local hlCommit="$1" + nix eval --raw --impure --expr ' + with builtins; let + hyprpm = fromTOML (readFile ./hyprpm.toml); + hlCommits = map head hyprpm.repository.commit_pins; + in + concatStringsSep "\n" hlCommits + ' | grep "$hlCommit" > /dev/null +} + +getHyprlandCommitFromRev() { + git ls-remote https://github.com/hyprwm/Hyprland.git "$1" \ + | cut -f 1 +} + +SCRIPT_DIR="$(dirname "$0")" + +hlTag="$("$SCRIPT_DIR/latest-hyprland-tag")" +echoerr "found latest Hyprland release: $hlTag" + +hlCommit="$(getHyprlandCommitFromRev "$hlTag")" +echoerr "-> commit: $hlCommit" + +if findHyprpmPin "$hlCommit"; then + echoerr "pin for tag $hlTag already found in hyprpm.toml" + exit 0 +fi + +echoerr "building and testing..." +commitPin="$("$SCRIPT_DIR/test-pin.sh" "$hlTag" "$HYPRGRASS_REV")" + +echoerr "pin tests passed: $commitPin" +echoerr 'updating hyprpm.toml' + +sed -i "/## DO NOT EDIT THIS LINE: for auto pin script ##/ i $commitPin" \ + hyprpm.toml + diff --git a/scripts/test-pin.sh b/scripts/ci/test-pin.sh similarity index 88% rename from scripts/test-pin.sh rename to scripts/ci/test-pin.sh index 844f527..d1f3933 100755 --- a/scripts/test-pin.sh +++ b/scripts/ci/test-pin.sh @@ -23,9 +23,7 @@ hyprgrassRev=${2:-main} hyprlandCommit="$(git ls-remote https://github.com/hyprwm/Hyprland.git "${hyprlandRev}" | cut -f 1)" hyprgrassCommit="$(git rev-parse "${hyprgrassRev}")" -git stash -git checkout "${hyprgrassRev}" -nix build --no-link .#hyprgrassWithTests \ +nix build --no-link "git+file://$(pwd)?rev=${hyprgrassRev}#hyprgrassWithTests" \ --override-input hyprland "github:hyprwm/Hyprland/${hyprlandRev}" \ echo "[\"${hyprlandCommit}\", \"${hyprgrassCommit}\"], # ${hyprlandRev}"