Skip to content

Commit 5f1be1c

Browse files
authored
Merge pull request #10 from cawalch/ps/rr/build__npm_build_and_publish_gh_actions_try_4
build: npm build and publish GH actions try 4
2 parents 0625b8d + 6a0c429 commit 5f1be1c

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

.github/workflows/publish.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,26 @@ jobs:
197197
find artifacts -name "*.node" -type f -exec cp {} . \;
198198
ls -la *.node
199199
200-
- name: Extract version from release
201-
id: extract_version
202-
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
200+
- name: Verify package version matches release
201+
id: verify_version
202+
run: |
203+
# Remove 'v' prefix if present
204+
TAG_NAME="${{ github.event.release.tag_name }}"
205+
RELEASE_VERSION="${TAG_NAME#v}"
206+
207+
# Get current version from package.json
208+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
203209
204-
- name: Set version in package.json
205-
run: npm version ${{ github.event.release.tag_name }} --no-git-tag-version
210+
echo "Release version: $RELEASE_VERSION"
211+
echo "Package version: $PACKAGE_VERSION"
212+
213+
# Skip version update if already correct
214+
if [ "$RELEASE_VERSION" = "$PACKAGE_VERSION" ]; then
215+
echo "Version already matches, no update needed"
216+
else
217+
echo "Updating version from $PACKAGE_VERSION to $RELEASE_VERSION"
218+
npm version $RELEASE_VERSION --no-git-tag-version
219+
fi
206220
207221
- name: Publish to npm
208222
run: npm publish --access public
@@ -215,3 +229,4 @@ jobs:
215229
tag_name: ${{ github.event.release.tag_name }}
216230
files: |
217231
*.node
232+

0 commit comments

Comments
 (0)