chore: version packages (#22) #23
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: | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: "20" | |
| registry-url: "https://registry.npmjs.org" | |
| - run: npm ci | |
| - run: npm test | |
| # Creates a "Version Packages" PR when changesets are pending, | |
| # or publishes to npm + creates GH Release when the Version PR is merged. | |
| - name: Create Version PR or Publish | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| version: npm run version | |
| publish: npm run release | |
| title: "chore: version packages" | |
| commit: "chore: version packages" | |
| createGithubReleases: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # GITHUB_TOKEN pushes don't trigger workflows on the Version Packages PR. | |
| # Close and reopen it so CI checks run without manual intervention. | |
| - name: Trigger CI on Version Packages PR | |
| if: steps.changesets.outputs.pullRequestNumber | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| PR=${{ steps.changesets.outputs.pullRequestNumber }} | |
| gh pr close "$PR" --comment "Closing to trigger CI checks" | |
| sleep 2 | |
| gh pr reopen "$PR" | |
| echo "Reopened Version Packages PR #$PR to trigger CI" |