Skip to content

Commit f25fd1a

Browse files
committed
ci: use plain semver tags
1 parent 498a5bd commit f25fd1a

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Publish npm Package
33
on:
44
push:
55
tags:
6-
- "v*.*.*"
6+
- "*.*.*"
77

88
permissions:
99
contents: read
@@ -30,8 +30,8 @@ jobs:
3030
shell: bash
3131
run: |
3232
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
33-
if [ "v${PACKAGE_VERSION}" != "${GITHUB_REF_NAME}" ]; then
34-
echo "Tag ${GITHUB_REF_NAME} does not match package.json version v${PACKAGE_VERSION}"
33+
if [ "${PACKAGE_VERSION}" != "${GITHUB_REF_NAME}" ]; then
34+
echo "Tag ${GITHUB_REF_NAME} does not match package.json version ${PACKAGE_VERSION}"
3535
exit 1
3636
fi
3737
@@ -41,5 +41,19 @@ jobs:
4141
- name: Verify package contents
4242
run: npm run release:check
4343

44+
- name: Check whether version already exists on npm
45+
id: npm_version
46+
shell: bash
47+
run: |
48+
PACKAGE_NAME="$(node -p "require('./package.json').name")"
49+
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
50+
if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version >/dev/null 2>&1; then
51+
echo "published=true" >> "$GITHUB_OUTPUT"
52+
echo "Version ${PACKAGE_VERSION} is already published. Skipping npm publish."
53+
else
54+
echo "published=false" >> "$GITHUB_OUTPUT"
55+
fi
56+
4457
- name: Publish package to npm
58+
if: steps.npm_version.outputs.published != 'true'
4559
run: npm publish --access public

RELEASING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ npm publishing is automated by GitHub Actions in [`.github/workflows/publish-npm
88

99
Normal pushes to `main` do not publish.
1010

11-
Only a pushed version tag such as `v0.3.1` triggers a release.
11+
Only a pushed version tag such as `0.3.1` triggers a release.
1212

1313
## Standard Release Flow
1414

@@ -67,15 +67,15 @@ npm run release:smoke
6767
After the version bump is committed on `main`, create and push the matching tag:
6868

6969
```bash
70-
git tag vX.Y.Z
71-
git push origin vX.Y.Z
70+
git tag X.Y.Z
71+
git push origin X.Y.Z
7272
```
7373

7474
Example:
7575

7676
```bash
77-
git tag v0.3.1
78-
git push origin v0.3.1
77+
git tag 0.3.1
78+
git push origin 0.3.1
7979
```
8080

8181
The workflow rejects the release if the Git tag does not exactly match `package.json`.

0 commit comments

Comments
 (0)