name: Publish to npm on: push: tags: - 'v*' permissions: contents: write packages: write id-token: write jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20.x' registry-url: 'https://registry.npmjs.org' - name: Setup Bun uses: oven-sh/setup-bun@v2 with: bun-version: latest - name: Install dependencies run: bun install --frozen-lockfile - name: Build run: bun run build:vite - name: Type check run: bun run typecheck - name: Run tests run: bun test - name: Publish to npm run: | VERSION="${GITHUB_REF_NAME#v}" TAG="latest" if [[ "$VERSION" == *"beta"* ]]; then TAG="beta" elif [[ "$VERSION" == *"alpha"* ]]; then TAG="alpha" elif [[ "$VERSION" == *"rc"* ]]; then TAG="rc" fi npm publish --tag "$TAG" --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Generate changelog id: changelog run: | PREV_TAG=$(git tag --sort=-version:refname | head -2 | tail -1) if [ "$PREV_TAG" = "$GITHUB_REF_NAME" ]; then PREV_TAG="" fi if [ -n "$PREV_TAG" ]; then COMMITS=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges) else COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges -20) fi { echo "commits<> "$GITHUB_OUTPUT" - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: name: ${{ github.ref_name }} body: | ## What's Changed ${{ steps.changelog.outputs.commits }} **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.ref_name }}^...${{ github.ref_name }} draft: false prerelease: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') }}