1#! /usr/bin/env nix-shell
2#! nix-shell -I nixpkgs=./. -i bash -p coreutils common-updater-scripts jq curl
3
4set -euo pipefail
5
6currentVersion="$(nix --extra-experimental-features nix-command eval -f . github-runner.version --raw)"
7latestVersion="$(curl -s -H "Accept: application/vnd.github.v3+json" \
8 ${GITHUB_TOKEN:+ -H "Authorization: bearer $GITHUB_TOKEN"} \
9 "https://api.github.com/repos/actions/runner/releases/latest" | jq -r ".tag_name")"
10latestVersion="${latestVersion#?}" # v2.296.2 -> 2.296.2
11
12if [[ "$latestVersion" == "$currentVersion" ]]; then
13 echo "github-runner is already up to date: $currentVersion"
14 exit
15fi
16
17update-source-version github-runner "$latestVersion"
18$(nix-build -A github-runner.fetch-deps --no-out-link) "$(dirname "$BASH_SOURCE")/deps.nix"
19