allow releasing tags #46
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: | |
| npm_tag: | |
| description: "npm dist-tag to publish under. Manual releases cannot use latest." | |
| required: true | |
| type: string | |
| 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 manual npm tag | |
| if: github.event_name == 'workflow_dispatch' | |
| env: | |
| NPM_TAG: ${{ inputs.npm_tag }} | |
| run: | | |
| if [ "$NPM_TAG" = "latest" ]; then | |
| echo "::error::Manual releases cannot publish to latest. Pushes to main publish to latest automatically." | |
| exit 1 | |
| fi | |
| if ! echo "$NPM_TAG" | grep -Eq '^[a-z][a-z0-9-]*$'; then | |
| echo "::error::npm_tag must match ^[a-z][a-z0-9-]*$." | |
| exit 1 | |
| fi | |
| - name: Build | |
| if: github.event_name == 'workflow_dispatch' | |
| run: npm run build | |
| # Manual dispatch publishes packages from the selected ref that are not | |
| # already on the registry under a non-latest npm dist-tag, for compatibility | |
| # or preview channels. It does not retag already-published versions. | |
| - name: Publish with manual npm tag | |
| if: github.event_name == 'workflow_dispatch' | |
| run: ./node_modules/.bin/changeset publish --tag "$NPM_TAG" | |
| env: | |
| NPM_TAG: ${{ inputs.npm_tag }} |