Skip to content

v4.0.0

v4.0.0 #5

Workflow file for this run

name: Publish
on:
release:
types:
- published
permissions:
contents: read
id-token: write
jobs:
publish:
name: Build and publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 24
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check
run: pnpm check
- name: Build
run: pnpm build
- name: Resolve npm dist-tag
id: dist_tag
env:
PRERELEASE: ${{ github.event.release.prerelease }}
TARGET: ${{ github.event.release.target_commitish }}
# Maintenance releases (e.g. from v3.x) must not steal `latest` from the current major
run: |
if [ "$PRERELEASE" = "true" ]; then
tag=next
elif [ "$TARGET" = "main" ]; then
tag=latest
else
# npm rejects dist-tags that parse as a SemVer range (e.g. plain "v3")
version=$(node -p "require('./package.json').version")
tag="v${version%%.*}-latest"
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Publish to npm
run: npm publish --access public --tag "${{ steps.dist_tag.outputs.tag }}"