Skip to content

Commit 9a110c1

Browse files
committed
ci: derive TAG_NAME from package.json when not a release
Use github.event.release.tag_name when set; otherwise set TAG_NAME to v-${version} from package.json so workflow_dispatch matches semver. Accept v0.2.0, 0.2.0, and v-0.2.0 in the version check. Made-with: Cursor
1 parent 2b893d6 commit 9a110c1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

.github/workflows/publish.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ jobs:
2929
PKG_VERSION="$(node -p "require('./package.json').version")"
3030
JSR_VERSION="$(node -p "require('./jsr.json').version")"
3131
TAG_NAME="${{ github.event.release.tag_name }}"
32+
if [[ -z "$TAG_NAME" ]]; then
33+
TAG_NAME="v-${PKG_VERSION}"
34+
fi
3235
if [[ "$PKG_VERSION" != "$JSR_VERSION" ]]; then
3336
echo "Version mismatch: package.json=$PKG_VERSION, jsr.json=$JSR_VERSION"
3437
exit 1
3538
fi
36-
if [[ "$TAG_NAME" != "v$PKG_VERSION" && "$TAG_NAME" != "$PKG_VERSION" ]]; then
37-
echo "Release tag '$TAG_NAME' does not match version '$PKG_VERSION' (expected '$PKG_VERSION' or 'v$PKG_VERSION')."
39+
if [[ "$TAG_NAME" != "v$PKG_VERSION" && "$TAG_NAME" != "$PKG_VERSION" && "$TAG_NAME" != "v-${PKG_VERSION}" ]]; then
40+
echo "Release tag '$TAG_NAME' does not match version '$PKG_VERSION' (expected '$PKG_VERSION', 'v$PKG_VERSION', or 'v-${PKG_VERSION}')."
3841
exit 1
3942
fi
4043

0 commit comments

Comments
 (0)