Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,54 @@ name: Release

on:
push:
branches: [master]
tags:
- 'v*'

permissions:
contents: write
deployments: write
issues: write
pull-requests: write
id-token: write

jobs:
release:
name: NPM
uses: node-modules/github-actions/.github/workflows/npm-release.yml@master
secrets:
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
name: Publish to NPM
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Setup Vite+
uses: voidzero-dev/setup-vp@v1
with:
node-version: '22'
cache: true
run-install: true

- name: Verify version matches tag
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
PKG_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
exit 1
fi

- name: Determine npm dist-tag
id: dist-tag
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
if echo "$TAG_VERSION" | grep -qE '-([a-zA-Z]+)'; then
# Extract pre-release identifier (e.g., "beta" from "5.0.0-beta.0")
PRE_TAG=$(echo "$TAG_VERSION" | sed -E 's/.*-([a-zA-Z]+).*/\1/')
echo "tag=$PRE_TAG" >> "$GITHUB_OUTPUT"
else
echo "tag=latest" >> "$GITHUB_OUTPUT"
fi
Comment on lines +39 to +46
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-release detection only matches tags with alphabetic identifiers (e.g., -beta). SemVer allows numeric-only prerelease identifiers like v1.0.0-0; those would fall into the latest branch and be published to the latest dist-tag and marked as a stable GitHub Release. Consider treating any version containing - as prerelease, and only mapping the identifier to a dist-tag when it is present/valid (otherwise default to a safe prerelease dist-tag like next).

Copilot uses AI. Check for mistakes.

- name: Publish to npm
run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }}
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm publish here doesn't provide any auth (e.g., NODE_AUTH_TOKEN) and also doesn't enable npm Trusted Publishing via OIDC. With only id-token: write, npm typically requires --provenance (or NPM_CONFIG_PROVENANCE=true) to perform the OIDC exchange; otherwise this step is likely to fail or fall back to token-based auth. Consider publishing with provenance (and/or explicitly configuring auth) to match the PR's stated OIDC release process.

Suggested change
run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }}
run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }} --provenance

Copilot uses AI. Check for mistakes.

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
prerelease: ${{ steps.dist-tag.outputs.tag != 'latest' }}
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,22 @@ Node.js v22.3.0
└─────────┴───────────────────────┴─────────┴────────────────────┴────────────┴─────────────────────────┘
```

## Release

Use `npm version` to bump the version, create a git tag, and push to trigger the release workflow.

```bash
# Stable release
npm version patch # or minor, major
git push origin master --tags

# Pre-release (beta, alpha, rc, etc.)
npm version 5.0.0-beta.0
git push origin master --tags
```

The [release workflow](.github/workflows/release.yml) will automatically publish to npm and create a GitHub Release when a `v*` tag is pushed. Pre-release tags (e.g., `v5.0.0-beta.0`) are published with the corresponding dist-tag (`beta`, `alpha`, `rc`, etc.).

## License

[MIT](LICENSE)
Expand Down
Loading