Skip to content

Commit 80025ef

Browse files
committed
chore: replace changesets with version-compare publish
1 parent 4d1e65e commit 80025ef

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

.github/workflows/publish.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: Publish to npm
33
on:
44
push:
55
branches: [main]
6-
workflow_dispatch:
76

87
concurrency:
98
group: publish
@@ -12,14 +11,8 @@ concurrency:
1211
jobs:
1312
publish:
1413
runs-on: ubuntu-latest
15-
permissions:
16-
contents: write
17-
pull-requests: write
18-
id-token: write
1914
steps:
2015
- uses: actions/checkout@v4
21-
with:
22-
fetch-depth: 0
2316

2417
- uses: pnpm/action-setup@v4
2518
with:
@@ -31,13 +24,19 @@ jobs:
3124
registry-url: https://registry.npmjs.org
3225

3326
- run: pnpm install --no-frozen-lockfile
27+
- run: pnpm build
3428

35-
- name: Create Release Pull Request or Publish
36-
id: changesets
37-
uses: changesets/action@v1
38-
with:
39-
publish: pnpm run release
29+
- name: Publish if version is new
30+
run: |
31+
PACKAGE_NAME=$(node -p "require('./package.json').name")
32+
LOCAL_VER=$(node -p "require('./package.json').version")
33+
NPM_VER=$(npm view "$PACKAGE_NAME" version 2>/dev/null || echo "0.0.0")
34+
35+
if [ "$LOCAL_VER" = "$NPM_VER" ]; then
36+
echo "v$LOCAL_VER already on npm — skipping"
37+
else
38+
npm publish --access public
39+
echo "Published $PACKAGE_NAME@$LOCAL_VER"
40+
fi
4041
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4342
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)