From 31af99e52f0acfbef606154f66b2f1eee8d7504d Mon Sep 17 00:00:00 2001 From: Pujit Mehrotra Date: Fri, 21 Nov 2025 10:16:00 -0500 Subject: [PATCH] chore: for releases, use tag as source of truth for API_VERSION (#1804) --- .github/workflows/build-plugin.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-plugin.yml b/.github/workflows/build-plugin.yml index a1c9d796f..c7e20bedb 100644 --- a/.github/workflows/build-plugin.yml +++ b/.github/workflows/build-plugin.yml @@ -78,7 +78,21 @@ jobs: GIT_SHA=$(git rev-parse --short HEAD) IS_TAGGED=$(git describe --tags --abbrev=0 --exact-match || echo '') PACKAGE_LOCK_VERSION=$(jq -r '.version' package.json) - API_VERSION=$([[ -n "$IS_TAGGED" ]] && echo "$PACKAGE_LOCK_VERSION" || echo "${PACKAGE_LOCK_VERSION}+${GIT_SHA}") + + # For release builds, trust the release tag version to avoid stale checkouts + if [ "${{ inputs.RELEASE_CREATED }}" = "true" ] && [ -n "${{ inputs.RELEASE_TAG }}" ]; then + TAG_VERSION="${{ inputs.RELEASE_TAG }}" + TAG_VERSION="${TAG_VERSION#v}" # trim leading v if present + + if [ "$TAG_VERSION" != "$PACKAGE_LOCK_VERSION" ]; then + echo "::warning::Release tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_LOCK_VERSION). Using tag version for TXZ naming." + fi + + API_VERSION="$TAG_VERSION" + else + API_VERSION=$([[ -n "$IS_TAGGED" ]] && echo "$PACKAGE_LOCK_VERSION" || echo "${PACKAGE_LOCK_VERSION}+${GIT_SHA}") + fi + echo "API_VERSION=${API_VERSION}" >> $GITHUB_OUTPUT - name: Install dependencies