test token #58
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| publish_latest: | |
| description: "Retry a failed latest publish (skips pre-mode check, publishes whatever's in package.json under the 'latest' tag). Leave off for normal prerelease dispatch." | |
| required: false | |
| default: false | |
| type: boolean | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Create Release PR or Publish | |
| if: github.event_name == 'push' | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| publish: npm run release | |
| title: "chore: release packages 📦" | |
| commit: "chore: release packages 📦" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Validate dispatch mode | |
| if: github.event_name == 'workflow_dispatch' | |
| env: | |
| PUBLISH_LATEST: ${{ inputs.publish_latest }} | |
| run: | | |
| if [ "$PUBLISH_LATEST" = "true" ]; then | |
| if [ -f .changeset/pre.json ]; then | |
| echo "::error::publish_latest is true but .changeset/pre.json exists. Exit pre mode before publishing to latest." | |
| exit 1 | |
| fi | |
| echo "publish_latest=true: will publish under 'latest' (retry path)." | |
| exit 0 | |
| fi | |
| if [ ! -f .changeset/pre.json ]; then | |
| echo "::error::Prerelease dispatch requires changesets pre mode. Run 'npx changeset pre enter <tag>' on the branch first, or re-dispatch with publish_latest=true to retry a latest publish." | |
| exit 1 | |
| fi | |
| - name: Build | |
| if: github.event_name == 'workflow_dispatch' | |
| run: npm run build | |
| # Manual dispatch publishes whatever's already versioned on the branch. | |
| # In pre mode, the dist-tag comes from .changeset/pre.json. | |
| # With publish_latest=true, it retries a failed latest publish (--provenance | |
| # mirrors the push-trigger path). | |
| - name: Publish (prerelease) | |
| if: github.event_name == 'workflow_dispatch' && inputs.publish_latest != true | |
| run: ./node_modules/.bin/changeset publish | |
| - name: Publish (latest retry) | |
| if: github.event_name == 'workflow_dispatch' && inputs.publish_latest == true | |
| run: ./node_modules/.bin/changeset publish --provenance |