Skip to content

Commit 2915ed8

Browse files
committed
add ci step to verify tag and package version match
Signed-off-by: karthik2804 <[email protected]>
1 parent 1448cc5 commit 2915ed8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

.github/workflows/release.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ jobs:
2222
node-version: 22
2323
registry-url: 'https://registry.npmjs.org/'
2424

25+
- name: Verify tag matches package version
26+
run: |
27+
PACKAGE_VERSION=$(jq -r .version package.json)
28+
TAG_VERSION=${{ github.ref_name }}
29+
# Remove 'v' prefix from the tag if it exists
30+
TAG_VERSION=${TAG_VERSION#v}
31+
32+
if [[ "$PACKAGE_VERSION" != "$TAG_VERSION" ]]; then
33+
echo "Error: Git tag ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
34+
exit 1
35+
fi
36+
2537
- name: Install dependencies
2638
run: npm ci
2739

@@ -46,6 +58,6 @@ jobs:
4658
env:
4759
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4860
run: |
49-
RELEASE_TAG=$(npm view . version)
61+
RELEASE_TAG=$(jq -r .version package.json)
5062
RELEASE_URL="https://www.npmjs.com/package/$(jq -r .name package.json)/v/$RELEASE_TAG"
5163
gh release create "v$RELEASE_TAG" --title "Release v$RELEASE_TAG" --notes "Published on npm: $RELEASE_URL"

0 commit comments

Comments
 (0)