Skip to content

Commit 31af99e

Browse files
authored
chore: for releases, use tag as source of truth for API_VERSION (#1804)
1 parent 933cefa commit 31af99e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

.github/workflows/build-plugin.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,21 @@ jobs:
7878
GIT_SHA=$(git rev-parse --short HEAD)
7979
IS_TAGGED=$(git describe --tags --abbrev=0 --exact-match || echo '')
8080
PACKAGE_LOCK_VERSION=$(jq -r '.version' package.json)
81-
API_VERSION=$([[ -n "$IS_TAGGED" ]] && echo "$PACKAGE_LOCK_VERSION" || echo "${PACKAGE_LOCK_VERSION}+${GIT_SHA}")
81+
82+
# For release builds, trust the release tag version to avoid stale checkouts
83+
if [ "${{ inputs.RELEASE_CREATED }}" = "true" ] && [ -n "${{ inputs.RELEASE_TAG }}" ]; then
84+
TAG_VERSION="${{ inputs.RELEASE_TAG }}"
85+
TAG_VERSION="${TAG_VERSION#v}" # trim leading v if present
86+
87+
if [ "$TAG_VERSION" != "$PACKAGE_LOCK_VERSION" ]; then
88+
echo "::warning::Release tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_LOCK_VERSION). Using tag version for TXZ naming."
89+
fi
90+
91+
API_VERSION="$TAG_VERSION"
92+
else
93+
API_VERSION=$([[ -n "$IS_TAGGED" ]] && echo "$PACKAGE_LOCK_VERSION" || echo "${PACKAGE_LOCK_VERSION}+${GIT_SHA}")
94+
fi
95+
8296
echo "API_VERSION=${API_VERSION}" >> $GITHUB_OUTPUT
8397
8498
- name: Install dependencies

0 commit comments

Comments
 (0)