github-runner: add update script

Co-authored-by: Ivar <ivar.scholten@protonmail.com>
This commit is contained in:
Vincent Haupert 2023-02-24 09:15:16 +01:00
parent 94d78e46ed
commit ab0eeaaa36
2 changed files with 21 additions and 0 deletions

View File

@ -353,6 +353,8 @@ stdenv.mkDerivation rec {
'';
};
passthru.updateScript = ./update.sh;
meta = with lib; {
description = "Self-hosted runner for GitHub Actions";
homepage = "https://github.com/actions/runner";

View File

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