From ab0eeaaa3687263741fcd5307587bd4be1902e48 Mon Sep 17 00:00:00 2001 From: Vincent Haupert Date: Fri, 24 Feb 2023 09:15:16 +0100 Subject: [PATCH] github-runner: add update script Co-authored-by: Ivar --- .../github-runner/default.nix | 2 ++ .../github-runner/update.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 pkgs/development/tools/continuous-integration/github-runner/update.sh diff --git a/pkgs/development/tools/continuous-integration/github-runner/default.nix b/pkgs/development/tools/continuous-integration/github-runner/default.nix index b1ff6a76f541..f56248e9926a 100644 --- a/pkgs/development/tools/continuous-integration/github-runner/default.nix +++ b/pkgs/development/tools/continuous-integration/github-runner/default.nix @@ -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"; diff --git a/pkgs/development/tools/continuous-integration/github-runner/update.sh b/pkgs/development/tools/continuous-integration/github-runner/update.sh new file mode 100755 index 000000000000..3ebbfa9f507c --- /dev/null +++ b/pkgs/development/tools/continuous-integration/github-runner/update.sh @@ -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" +