1
0
mirror of https://github.com/nvm-sh/nvm.git synced 2026-10-24 07:13:42 +08:00

[actions] nodejs.org PR: fix force boolean and grab the latest tag on dispatch

The branch-reset step sent `force` as a string via `gh api -f "force=true"`,
which the Git refs API rejects ("not a boolean", HTTP 422), failing the release run.
Use `-F` so it is sent as a boolean.

Also resolve the version from the latest `vX.Y.Z` tag
(via the tags API) rather than `releases/latest`,
so a manual `workflow_dispatch` with no input works even before the GitHub release object for a freshly pushed tag is published.
This commit is contained in:
Jordan Harband
2026-06-04 09:54:01 -07:00
parent 77fca77ddd
commit 306f04a90a

View File

@@ -7,7 +7,7 @@ on:
workflow_dispatch:
inputs:
version:
description: 'nvm version tag (e.g., v0.40.4). Defaults to latest release.'
description: 'nvm version tag (e.g., v0.40.4). Defaults to the latest version tag.'
required: false
default: ''
@@ -41,7 +41,8 @@ jobs:
elif [ "${GITHUB_REF_TYPE}" = "tag" ]; then
TAG="${GITHUB_REF#refs/tags/}"
else
TAG="$(gh api "repos/${GITHUB_REPOSITORY}/releases/latest" --jq '.tag_name')"
TAG="$(gh api --paginate "repos/${GITHUB_REPOSITORY}/tags" --jq '.[].name' \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1)"
fi
if ! printf '%s\n' "${TAG}" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
@@ -74,7 +75,7 @@ jobs:
gh api "repos/${FORK_OWNER}/nodejs.org/git/refs/heads/${BRANCH}" \
-X PATCH \
-f "sha=${UPSTREAM_SHA}" \
-f "force=true" > /dev/null
-F "force=true" > /dev/null
fi
printf 'fork_owner=%s\n' "${FORK_OWNER}" >> "${GITHUB_OUTPUT}"