diff --git a/.forgejo/workflows/bump-libmpv.yml b/.forgejo/workflows/bump-libmpv.yml new file mode 100644 index 0000000..71a3865 --- /dev/null +++ b/.forgejo/workflows/bump-libmpv.yml @@ -0,0 +1,24 @@ +name: "Bump the Windows build's libmpv" + +on: + schedule: + - cron: "0 6 * * 1" + workflow_dispatch: + +jobs: + bump-libmpv: + runs-on: ["small", "debian-13-x86_64"] + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Lix GHA Installer Action + uses: samueldr/lix-gha-installer-action@v2026-02-22 + with: + extra_nix_config: experimental-features = nix-command flakes flake-self-attrs + + - name: Open a PR if there's a newer libmpv build + env: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: nix run .#bump-libmpv diff --git a/linux/nix/bump_libmpv.sh b/linux/nix/bump_libmpv.sh new file mode 100644 index 0000000..02a74f1 --- /dev/null +++ b/linux/nix/bump_libmpv.sh @@ -0,0 +1,60 @@ +# shellcheck shell=bash + +# Opens a PR bumping the libmpv build that the Windows CI downloads, if +# mpv-winbuild-cmake has published a newer one. Run it from the repo root, with +# TOKEN set to a Forgejo token that can push branches and open PRs. + +# Checked first, so that nothing is pushed if the PR can't be opened +: "${TOKEN:?needs a Forgejo token}" +: "${GITHUB_SERVER_URL:?is set by Forgejo Actions}" +: "${GITHUB_REPOSITORY:?is set by Forgejo Actions}" +: "${GITHUB_REF_NAME:?is set by Forgejo Actions}" + +workflow=.github/workflows/windows.yml +current_url=$(grep -oE 'https://github\.com/shinchiro/mpv-winbuild-cmake/releases/download/[^"]+\.7z' "$workflow") +current_hash=$(grep -oE -- '-ne "[0-9a-f]{64}"' "$workflow" | grep -oE '[0-9a-f]{64}') + +release=$(curl -fsSL https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/latest) +tag=$(jq -r .tag_name <<<"$release") +url=$(jq -r '.assets[] | select(.name | test("^mpv-dev-x86_64-[0-9]{8}-git-[0-9a-f]+\\.7z$")) | .browser_download_url' <<<"$release") + +if [ -z "$url" ]; then + echo "Release $tag has no x86_64 libmpv archive" >&2 + exit 1 +fi +if [ "$url" = "$current_url" ]; then + echo "libmpv is up to date ($tag)" + exit 0 +fi + +branch="bump-libmpv-$tag" +if git ls-remote --exit-code --heads origin "$branch" >/dev/null; then + echo "$branch already exists, so its PR should already be open" + exit 0 +fi + +archive=$(mktemp) +curl -fsSL "$url" -o "$archive" +hash=$(sha256sum "$archive" | cut -d " " -f 1) +rm "$archive" + +sed -i "s|$current_url|$url|; s|$current_hash|$hash|" "$workflow" + +git config user.name "Forgejo Actions" +git config user.email "forgejo-actions@noreply.git.federated.nexus" +git switch -c "$branch" +git commit -am "bump libmpv to $tag" +git push origin "$branch" + +curl -fsS -X POST "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/pulls" \ + -H "Authorization: token $TOKEN" \ + -H "Content-Type: application/json" \ + -d "$(jq -n \ + --arg head "$branch" \ + --arg base "$GITHUB_REF_NAME" \ + --arg title "Bump libmpv to $tag" \ + --arg body "Updates the libmpv build that the Windows CI bundles to [$tag](https://github.com/shinchiro/mpv-winbuild-cmake/releases/tag/$tag)." \ + '{head: $head, base: $base, title: $title, body: $body}')" \ + >/dev/null + +echo "Opened a PR bumping libmpv to $tag" diff --git a/linux/nix/default.nix b/linux/nix/default.nix index 3d3b395..4fc6983 100644 --- a/linux/nix/default.nix +++ b/linux/nix/default.nix @@ -78,6 +78,24 @@ program = lib.getExe e2e; }; + bump-libmpv = { + type = "app"; + program = lib.getExe ( + pkgs.writeShellApplication { + name = "nexus-bump-libmpv"; + runtimeInputs = with pkgs; [ + coreutils + curl + git + gnugrep + gnused + jq + ]; + text = builtins.readFile ./bump_libmpv.sh; + } + ); + }; + e2e-headless = { type = "app"; program = lib.getExe (