|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - trunk |
| 7 | + - develop |
| 8 | + |
| 9 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 10 | + |
| 11 | +permissions: |
| 12 | + id-token: write # Required for OIDC token generation |
| 13 | + contents: write # Required for changesets to push commits/tags |
| 14 | + pull-requests: write # Required for changesets to create release PRs |
| 15 | + |
| 16 | +jobs: |
| 17 | + release: |
| 18 | + name: Release |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout Repo |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Setup Node.js 20.x |
| 25 | + uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: 20.x |
| 28 | + registry-url: 'https://registry.npmjs.org' |
| 29 | + |
| 30 | + - name: Install Dependencies |
| 31 | + run: npm ci |
| 32 | + |
| 33 | + - name: Promote from @next |
| 34 | + if: github.ref_name == 'trunk' |
| 35 | + run: | |
| 36 | + [[ -f .changeset/pre.json ]] && { git config user.email "github-actions[bot]@users.noreply.github.com"; git config user.name "github-actions[bot]"; npx changeset pre exit; npx changeset version; git add -u; git commit -m "chore: promote from @next" --no-verify; git push --follow-tags; } || echo 'not in pre mode, no need to exit' |
| 37 | +
|
| 38 | + - name: Enter pre next |
| 39 | + if: github.ref_name == 'develop' |
| 40 | + run: | |
| 41 | + [[ ! -f .changeset/pre.json ]] && npx changeset pre enter next || echo 'already in pre mode' |
| 42 | +
|
| 43 | + - name: Create Release Pull Request or Publish to npm |
| 44 | + id: changesets |
| 45 | + uses: changesets/action@v1 |
| 46 | + with: |
| 47 | + publish: npx changeset publish |
| 48 | + commit: | |
| 49 | + ${{ github.ref_name == 'develop' && 'chore: version packages (next)' || 'chore: version packages' }} |
| 50 | + createGithubReleases: true |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + |
| 54 | + merge-to-develop: |
| 55 | + name: Merge trunk to develop |
| 56 | + runs-on: ubuntu-latest |
| 57 | + needs: release |
| 58 | + if: github.ref_name == 'trunk' |
| 59 | + steps: |
| 60 | + - name: Checkout Repo |
| 61 | + uses: actions/checkout@v4 |
| 62 | + with: |
| 63 | + fetch-depth: 0 |
| 64 | + ref: develop |
| 65 | + |
| 66 | + - name: Configure Git |
| 67 | + run: | |
| 68 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 69 | + git config user.name "github-actions[bot]" |
| 70 | +
|
| 71 | + - name: Merge trunk into develop |
| 72 | + run: | |
| 73 | + git fetch origin trunk |
| 74 | + git merge origin/trunk --no-edit -m "chore: merge trunk into develop" |
| 75 | + git push origin develop |
0 commit comments