name: Publish Stable Release to NPM on: push: branches: - main workflow_dispatch: inputs: dry_run: description: "Run Changesets versioning without publishing" required: true default: true type: boolean permissions: contents: write pull-requests: write id-token: write jobs: version: runs-on: ubuntu-latest strategy: matrix: node-version: [26.x] steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup pnpm uses: pnpm/action-setup@v4 with: version: 10.8.1 - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: "pnpm" registry-url: "https://registry.npmjs.org" - name: Update npm for trusted publishing run: npm install -g npm@^11.5.1 - name: Install dependencies run: pnpm install --frozen-lockfile - name: Dry run Changesets version if: github.event_name == 'workflow_dispatch' run: | if [ "${{ inputs.dry_run }}" != "true" ]; then echo "Manual stable publishing is disabled. Use dry_run=true." exit 1 fi pnpm version-packages { echo "# Changesets Dry Run" echo echo "Ran \`pnpm version-packages\` without publishing." echo echo "## Resulting workspace changes" echo echo '```' git status --short echo '```' } >> "$GITHUB_STEP_SUMMARY" - name: Exclude separately released packages from the stable release decision if: github.event_name == 'push' run: node scripts/prepare-stable-release.cjs - name: Create version PR or publish if: github.event_name == 'push' # v2 is required for @changesets/cli v3. v1 parses CLI v2 stdout to find # published packages, so with CLI v3 it silently skips git tags and # GitHub releases (which also feed the website changelog). # Pinned to v2.1.2: it is the first v2 release whose version step resets # the checkout before committing in the default GitHub API push mode, # which restores the changesets prepare-stable-release.cjs hides. # v2.0.0 through v2.1.1 skip that reset and would commit their deletion. uses: changesets/action@v2.1.2 with: version-script: pnpm version-packages publish-script: pnpm publish-packages env: # setup-node's npmrc (registry-url above) supplies npm auth; v2 no # longer writes an .npmrc from NPM_TOKEN. NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: "true"