Skip to content

Commit c7cb003

Browse files
author
strausr
committed
fix: check version change before publishing to npm
1 parent e2dbe19 commit c7cb003

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ jobs:
9797
echo "=== Git tags ==="
9898
git tag
9999
100+
- name: Get version before semantic-release
101+
id: version-before
102+
run: |
103+
VERSION_BEFORE=$(node -p "require('./package.json').version")
104+
echo "version=$VERSION_BEFORE" >> $GITHUB_OUTPUT
105+
echo "Current version: $VERSION_BEFORE"
106+
100107
- name: Release with semantic-release
101108
id: release
102109
env:
@@ -113,18 +120,22 @@ jobs:
113120
echo "✓ Using .npmrc for authentication"
114121
fi
115122
116-
# Get version from package.json (updated by semantic-release)
117-
VERSION=$(node -p "require('./package.json').version")
118-
CURRENT_TAG=$(git describe --tags --exact-match 2>/dev/null || echo "")
123+
# Get versions
124+
VERSION_BEFORE="${{ steps.version-before.outputs.version }}"
125+
VERSION_AFTER=$(node -p "require('./package.json').version")
126+
127+
echo "Version before: $VERSION_BEFORE"
128+
echo "Version after: $VERSION_AFTER"
119129
120130
# Only publish if semantic-release created a new version
121-
if [ -n "$CURRENT_TAG" ]; then
122-
echo "New release detected: $CURRENT_TAG"
123-
echo "Publishing version: $VERSION"
131+
if [ "$VERSION_BEFORE" != "$VERSION_AFTER" ]; then
132+
echo "New version detected: $VERSION_AFTER"
133+
echo "Publishing to npm..."
124134
125135
# Publish using npm publish which supports OIDC/trusted publishing
126136
npm publish --provenance --access public
127-
echo "✓ Published $VERSION to npm"
137+
echo "✓ Published $VERSION_AFTER to npm"
128138
else
129-
echo "No new release created, skipping npm publish"
139+
echo "No version change detected (version: $VERSION_AFTER)"
140+
echo "Skipping npm publish - no new release was created"
130141
fi

0 commit comments

Comments
 (0)