chore: replace changesets with version-compare publish #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to npm | |
| on: | |
| push: | |
| branches: [main] | |
| concurrency: | |
| group: publish | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org | |
| - run: pnpm install --no-frozen-lockfile | |
| - run: pnpm build | |
| - name: Publish if version is new | |
| run: | | |
| PACKAGE_NAME=$(node -p "require('./package.json').name") | |
| LOCAL_VER=$(node -p "require('./package.json').version") | |
| NPM_VER=$(npm view "$PACKAGE_NAME" version 2>/dev/null || echo "0.0.0") | |
| if [ "$LOCAL_VER" = "$NPM_VER" ]; then | |
| echo "v$LOCAL_VER already on npm — skipping" | |
| else | |
| npm publish --access public | |
| echo "Published $PACKAGE_NAME@$LOCAL_VER" | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |