Skip to content

Commit 29e336b

Browse files
committed
fix(ci): prevent duplicate version publishing and update CLI command name
1 parent 7b931d0 commit 29e336b

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,15 @@ jobs:
108108
echo "no-bump=true" >> $GITHUB_OUTPUT
109109
echo "No version bump needed - already tagged"
110110
else
111-
echo "no-bump=false" >> $GITHUB_OUTPUT
112-
echo "Version bump needed"
111+
# Check if the current version already exists on npm
112+
CURRENT_VERSION=$(node -p "require('./package.json').version")
113+
if npm view @alloylab/collection-registry@$CURRENT_VERSION version >/dev/null 2>&1; then
114+
echo "no-bump=true" >> $GITHUB_OUTPUT
115+
echo "Version $CURRENT_VERSION already exists on npm - skipping publish"
116+
else
117+
echo "no-bump=false" >> $GITHUB_OUTPUT
118+
echo "Version bump needed"
119+
fi
113120
fi
114121
115122
- name: Auto-increment version
@@ -143,8 +150,21 @@ jobs:
143150
git push origin main
144151
git push origin "v$NEW_VERSION"
145152
146-
- name: Publish to npm
153+
- name: Check if version exists on npm
147154
if: steps.version-check.outputs.no-bump == 'false'
155+
id: version-exists
156+
run: |
157+
NEW_VERSION=$(node -p "require('./package.json').version")
158+
if npm view @alloylab/collection-registry@$NEW_VERSION version >/dev/null 2>&1; then
159+
echo "exists=true" >> $GITHUB_OUTPUT
160+
echo "Version $NEW_VERSION already exists on npm"
161+
else
162+
echo "exists=false" >> $GITHUB_OUTPUT
163+
echo "Version $NEW_VERSION is new and can be published"
164+
fi
165+
166+
- name: Publish to npm
167+
if: steps.version-check.outputs.no-bump == 'false' && steps.version-exists.outputs.exists == 'false'
148168
run: pnpm publish --access public
149169
env:
150170
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ pnpm add @alloylab/collection-registry
3131

3232
```bash
3333
# Run with default paths
34-
npx collectionRegistry
34+
npx collection-registry
3535

3636
# Or specify custom paths
37-
npx collectionRegistry \
37+
npx collection-registry \
3838
--collections-path ./cms/src/collections \
3939
--output-path ./web/app/lib \
4040
--types-path ./cms/src/payload-types.ts
@@ -308,7 +308,7 @@ const customTypeMap = {
308308
Enable debug logging:
309309

310310
```bash
311-
DEBUG=collectionRegistry npx collectionRegistry
311+
DEBUG=collectionRegistry npx collection-registry
312312
```
313313

314314
## Versioning

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "dist/index.js",
66
"type": "module",
77
"bin": {
8-
"collectionRegistry": "./dist/bin.js"
8+
"collection-registry": "./dist/bin.js"
99
},
1010
"files": [
1111
"dist",

0 commit comments

Comments
 (0)