From 2d61403223977e940277e1d8a667fa6676fdb1d2 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Tue, 3 Dec 2024 12:49:46 -0500 Subject: [PATCH] Fix release workflow with PRs from forks (#332) PR #329 failed to create a release because the release workflow ran in the context of the fork: ``` Run peter-evans/create-pull-request@v5 Error: Input 'token' not supplied. Unable to continue. Restore git configuration Error: Cannot read properties of undefined (reading 'removeAuth') ``` Change the workflow to run in `pull_request_target` to fix this, I hope. Also update `get-crate-version` to not depend on any runtime tools, only the Nix expressions. See: https://github.com/MercuryTechnologies/ghciwatch/actions/runs/12130981516/job/33822389311 --- .github/workflows/version.yaml | 2 +- nix/packages/get-crate-version.nix | 24 +++--------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index 8bbbd926..64dfe403 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -9,7 +9,7 @@ # and update the `REPO_GITHUB_TOKEN` secret to a new, valid token. on: - pull_request: + pull_request_target: types: - closed branches: diff --git a/nix/packages/get-crate-version.nix b/nix/packages/get-crate-version.nix index 28437d5f..baf14ead 100644 --- a/nix/packages/get-crate-version.nix +++ b/nix/packages/get-crate-version.nix @@ -1,30 +1,12 @@ { + lib, writeShellApplication, - cargo, - jq, + ghciwatch, }: writeShellApplication { name = "get-crate-version"; - runtimeInputs = [ - cargo - jq - ]; - text = '' - # Gets the version of `ghciwatch` in `Cargo.toml` using - # `cargo metadata` and `jq`. - - VERSION=$(cargo metadata --format-version 1 \ - | jq -r '.packages[] | select(.name == "ghciwatch") | .version') - - echo "Version in \`Cargo.toml\` is $VERSION" 1>&2 - - if [[ -z "$VERSION" ]]; then - echo "I wasn't able to determine the version in \`Cargo.toml\` with \`cargo metadata\`" - exit 1 - fi - - echo "$VERSION" + echo ${lib.escapeShellArg ghciwatch.version} ''; }