|
| 1 | +# D: Manual Dispatch |
| 2 | +# M: Merge release PR |
| 3 | +# C: Commit |
| 4 | +# ┌───────────┐ ┌─────────────┐ ┌────────────────┐ |
| 5 | +# │Development├──D──►RC-Unreleased│ ┌──►Final-Unreleased│ |
| 6 | +# └───────────┘ └─┬─────────▲─┘ │ └─┬────────────▲─┘ |
| 7 | +# │ │ │ │ │ |
| 8 | +# M C D M C |
| 9 | +# │ │ │ │ │ |
| 10 | +# ┌▼─────────┴┐ │ ┌▼────────────┴┐ |
| 11 | +# │RC-Released├───┘ │Final-Released│ |
| 12 | +# └───────────┘ └──────────────┘ |
| 13 | +name: Release Cycle |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + branches: |
| 18 | + - release-v* |
| 19 | + workflow_dispatch: {} |
| 20 | + |
| 21 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 22 | + |
| 23 | +jobs: |
| 24 | + state: |
| 25 | + name: Check state |
| 26 | + permissions: |
| 27 | + pull-requests: read |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + submodules: recursive |
| 33 | + - name: Set up environment |
| 34 | + uses: ./.github/actions/setup |
| 35 | + - id: state |
| 36 | + name: Get state |
| 37 | + uses: actions/github-script@v7 |
| 38 | + env: |
| 39 | + TRIGGERING_ACTOR: ${{ github.triggering_actor }} |
| 40 | + with: |
| 41 | + result-encoding: string |
| 42 | + script: await require('./scripts/release/workflow/state.js')({ github, context, core }) |
| 43 | + outputs: |
| 44 | + # Job Flags |
| 45 | + start: ${{ steps.state.outputs.start }} |
| 46 | + changesets: ${{ steps.state.outputs.changesets }} |
| 47 | + promote: ${{ steps.state.outputs.promote }} |
| 48 | + publish: ${{ steps.state.outputs.publish }} |
| 49 | + merge: ${{ steps.state.outputs.merge }} |
| 50 | + |
| 51 | + # Global variables |
| 52 | + is_prerelease: ${{ steps.state.outputs.is_prerelease }} |
| 53 | + |
| 54 | + start: |
| 55 | + needs: state |
| 56 | + name: Start new release candidate |
| 57 | + permissions: |
| 58 | + contents: write |
| 59 | + actions: write |
| 60 | + if: needs.state.outputs.start == 'true' |
| 61 | + runs-on: ubuntu-latest |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v4 |
| 64 | + with: |
| 65 | + submodules: recursive |
| 66 | + - name: Set up environment |
| 67 | + uses: ./.github/actions/setup |
| 68 | + - run: bash scripts/git-user-config.sh |
| 69 | + - id: start |
| 70 | + name: Create branch with release candidate |
| 71 | + run: bash scripts/release/workflow/start.sh |
| 72 | + - name: Re-run workflow |
| 73 | + uses: actions/github-script@v7 |
| 74 | + env: |
| 75 | + REF: ${{ steps.start.outputs.branch }} |
| 76 | + with: |
| 77 | + script: await require('./scripts/release/workflow/rerun.js')({ github, context }) |
| 78 | + |
| 79 | + promote: |
| 80 | + needs: state |
| 81 | + name: Promote to final release |
| 82 | + permissions: |
| 83 | + contents: write |
| 84 | + actions: write |
| 85 | + if: needs.state.outputs.promote == 'true' |
| 86 | + runs-on: ubuntu-latest |
| 87 | + steps: |
| 88 | + - uses: actions/checkout@v4 |
| 89 | + with: |
| 90 | + submodules: recursive |
| 91 | + - name: Set up environment |
| 92 | + uses: ./.github/actions/setup |
| 93 | + - run: bash scripts/git-user-config.sh |
| 94 | + - name: Exit prerelease state |
| 95 | + if: needs.state.outputs.is_prerelease == 'true' |
| 96 | + run: bash scripts/release/workflow/exit-prerelease.sh |
| 97 | + - name: Re-run workflow |
| 98 | + uses: actions/github-script@v7 |
| 99 | + with: |
| 100 | + script: await require('./scripts/release/workflow/rerun.js')({ github, context }) |
| 101 | + |
| 102 | + changesets: |
| 103 | + needs: state |
| 104 | + name: Update PR to release |
| 105 | + permissions: |
| 106 | + contents: write |
| 107 | + pull-requests: write |
| 108 | + if: needs.state.outputs.changesets == 'true' |
| 109 | + runs-on: ubuntu-latest |
| 110 | + steps: |
| 111 | + - uses: actions/checkout@v4 |
| 112 | + with: |
| 113 | + fetch-depth: 0 # To get all tags |
| 114 | + submodules: recursive |
| 115 | + - name: Set up environment |
| 116 | + uses: ./.github/actions/setup |
| 117 | + - name: Set release title |
| 118 | + uses: actions/github-script@v7 |
| 119 | + with: |
| 120 | + result-encoding: string |
| 121 | + script: await require('./scripts/release/workflow/set-changesets-pr-title.js')({ core }) |
| 122 | + - name: Create PR |
| 123 | + uses: changesets/action@v1 |
| 124 | + env: |
| 125 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 126 | + PRERELEASE: ${{ needs.state.outputs.is_prerelease }} |
| 127 | + with: |
| 128 | + version: npm run version |
| 129 | + title: ${{ env.TITLE }} |
| 130 | + commit: ${{ env.TITLE }} |
| 131 | + body: | # Wait for support on this https://github.com/changesets/action/pull/250 |
| 132 | + This is an automated PR for releasing ${{ github.repository }} |
| 133 | + Check [CHANGELOG.md](${{ github.repository }}/CHANGELOG.md) |
| 134 | +
|
| 135 | + publish: |
| 136 | + needs: state |
| 137 | + name: Publish to npm |
| 138 | + environment: npm |
| 139 | + permissions: |
| 140 | + contents: write |
| 141 | + id-token: write |
| 142 | + if: needs.state.outputs.publish == 'true' |
| 143 | + runs-on: ubuntu-latest |
| 144 | + steps: |
| 145 | + - uses: actions/checkout@v4 |
| 146 | + with: |
| 147 | + submodules: recursive |
| 148 | + - name: Set up environment |
| 149 | + uses: ./.github/actions/setup |
| 150 | + - id: pack |
| 151 | + name: Pack |
| 152 | + run: bash scripts/release/workflow/pack.sh |
| 153 | + env: |
| 154 | + PRERELEASE: ${{ needs.state.outputs.is_prerelease }} |
| 155 | + - name: Upload tarball artifact |
| 156 | + uses: actions/upload-artifact@v4 |
| 157 | + with: |
| 158 | + name: ${{ github.ref_name }} |
| 159 | + path: ${{ steps.pack.outputs.tarball }} |
| 160 | + - name: Publish |
| 161 | + run: bash scripts/release/workflow/publish.sh |
| 162 | + env: |
| 163 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 164 | + TARBALL: ${{ steps.pack.outputs.tarball }} |
| 165 | + TAG: ${{ steps.pack.outputs.tag }} |
| 166 | + NPM_CONFIG_PROVENANCE: true |
| 167 | + - name: Create Github Release |
| 168 | + uses: actions/github-script@v7 |
| 169 | + env: |
| 170 | + PRERELEASE: ${{ needs.state.outputs.is_prerelease }} |
| 171 | + with: |
| 172 | + script: await require('./scripts/release/workflow/github-release.js')({ github, context }) |
| 173 | + outputs: |
| 174 | + tarball_name: ${{ steps.pack.outputs.tarball_name }} |
| 175 | + |
| 176 | + integrity_check: |
| 177 | + needs: publish |
| 178 | + name: Tarball Integrity Check |
| 179 | + runs-on: ubuntu-latest |
| 180 | + steps: |
| 181 | + - uses: actions/checkout@v4 |
| 182 | + with: |
| 183 | + submodules: recursive |
| 184 | + - name: Download tarball artifact |
| 185 | + id: artifact |
| 186 | + uses: actions/download-artifact@v4 |
| 187 | + with: |
| 188 | + name: ${{ github.ref_name }} |
| 189 | + - name: Check integrity |
| 190 | + run: bash scripts/release/workflow/integrity-check.sh |
| 191 | + env: |
| 192 | + TARBALL: ${{ steps.artifact.outputs.download-path }}/${{ needs.publish.outputs.tarball_name }} |
| 193 | + |
| 194 | + merge: |
| 195 | + needs: state |
| 196 | + name: Create PR back to master |
| 197 | + permissions: |
| 198 | + contents: write |
| 199 | + pull-requests: write |
| 200 | + if: needs.state.outputs.merge == 'true' |
| 201 | + runs-on: ubuntu-latest |
| 202 | + env: |
| 203 | + MERGE_BRANCH: merge/${{ github.ref_name }} |
| 204 | + steps: |
| 205 | + - uses: actions/checkout@v4 |
| 206 | + with: |
| 207 | + fetch-depth: 0 # All branches |
| 208 | + submodules: recursive |
| 209 | + - name: Set up environment |
| 210 | + uses: ./.github/actions/setup |
| 211 | + - run: bash scripts/git-user-config.sh |
| 212 | + - name: Create branch to merge |
| 213 | + run: | |
| 214 | + git checkout -B "$MERGE_BRANCH" "$GITHUB_REF_NAME" |
| 215 | + git push -f origin "$MERGE_BRANCH" |
| 216 | + - name: Create PR back to master |
| 217 | + uses: actions/github-script@v7 |
| 218 | + with: |
| 219 | + script: | |
| 220 | + await github.rest.pulls.create({ |
| 221 | + owner: context.repo.owner, |
| 222 | + repo: context.repo.repo, |
| 223 | + head: process.env.MERGE_BRANCH, |
| 224 | + base: 'master', |
| 225 | + title: '${{ format('Merge {0} branch', github.ref_name) }}' |
| 226 | + }); |
0 commit comments