release-cycle.yml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. on:
  15. push:
  16. branches:
  17. - release-v*
  18. workflow_dispatch: {}
  19. concurrency: ${{ github.workflow }}-${{ github.ref }}
  20. jobs:
  21. state:
  22. name: Check state
  23. permissions:
  24. pull-requests: read
  25. runs-on: ubuntu-latest
  26. steps:
  27. - uses: actions/checkout@v3
  28. - name: Set up environment
  29. uses: ./.github/actions/setup
  30. - id: state
  31. name: Get state
  32. uses: actions/github-script@v6
  33. env:
  34. TRIGGERING_ACTOR: ${{ github.triggering_actor }}
  35. with:
  36. result-encoding: string
  37. script: await require('./scripts/release/workflow/state.js')({ github, context, core })
  38. outputs:
  39. # Job Flags
  40. start: ${{ steps.state.outputs.start }}
  41. changesets: ${{ steps.state.outputs.changesets }}
  42. promote: ${{ steps.state.outputs.promote }}
  43. publish: ${{ steps.state.outputs.publish }}
  44. merge: ${{ steps.state.outputs.merge }}
  45. # Global variables
  46. is_prerelease: ${{ steps.state.outputs.is_prerelease }}
  47. start:
  48. needs: state
  49. name: Start new release candidate
  50. permissions:
  51. contents: write
  52. actions: write
  53. if: needs.state.outputs.start == 'true'
  54. runs-on: ubuntu-latest
  55. steps:
  56. - uses: actions/checkout@v3
  57. - name: Set up environment
  58. uses: ./.github/actions/setup
  59. - run: bash scripts/git-user-config.sh
  60. - id: start
  61. name: Create branch with release candidate
  62. run: bash scripts/release/workflow/start.sh
  63. - name: Re-run workflow
  64. uses: actions/github-script@v6
  65. env:
  66. REF: ${{ steps.start.outputs.branch }}
  67. with:
  68. script: await require('./scripts/release/workflow/rerun.js')({ github, context })
  69. promote:
  70. needs: state
  71. name: Promote to final release
  72. permissions:
  73. contents: write
  74. actions: write
  75. if: needs.state.outputs.promote == 'true'
  76. runs-on: ubuntu-latest
  77. steps:
  78. - uses: actions/checkout@v3
  79. - name: Set up environment
  80. uses: ./.github/actions/setup
  81. - run: bash scripts/git-user-config.sh
  82. - name: Exit prerelease state
  83. if: needs.state.outputs.is_prerelease == 'true'
  84. run: bash scripts/release/workflow/exit-prerelease.sh
  85. - name: Re-run workflow
  86. uses: actions/github-script@v6
  87. with:
  88. script: await require('./scripts/release/workflow/rerun.js')({ github, context })
  89. changesets:
  90. needs: state
  91. name: Update PR to release
  92. permissions:
  93. contents: write
  94. pull-requests: write
  95. if: needs.state.outputs.changesets == 'true'
  96. runs-on: ubuntu-latest
  97. steps:
  98. - uses: actions/checkout@v3
  99. with:
  100. fetch-depth: 0 # To get all tags
  101. - name: Set up environment
  102. uses: ./.github/actions/setup
  103. - name: Set release title
  104. uses: actions/github-script@v6
  105. with:
  106. result-encoding: string
  107. script: await require('./scripts/release/workflow/set-changesets-pr-title.js')({ core })
  108. - name: Create PR
  109. uses: changesets/action@v1
  110. env:
  111. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  112. PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
  113. with:
  114. version: npm run version
  115. title: ${{ env.TITLE }}
  116. commit: ${{ env.TITLE }}
  117. body: | # Wait for support on this https://github.com/changesets/action/pull/250
  118. This is an automated PR for releasing ${{ github.repository }}
  119. Check [CHANGELOG.md](${{ github.repository }}/CHANGELOG.md)
  120. publish:
  121. needs: state
  122. name: Publish to npm
  123. environment: npm
  124. permissions:
  125. contents: write
  126. if: needs.state.outputs.publish == 'true'
  127. runs-on: ubuntu-latest
  128. steps:
  129. - uses: actions/checkout@v3
  130. - name: Set up environment
  131. uses: ./.github/actions/setup
  132. - id: pack
  133. name: Pack
  134. run: bash scripts/release/workflow/pack.sh
  135. env:
  136. PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
  137. - name: Tag
  138. run: npx changeset tag
  139. - name: Publish
  140. run: bash scripts/release/workflow/publish.sh
  141. env:
  142. NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
  143. TARBALL: ${{ steps.pack.outputs.tarball }}
  144. TAG: ${{ steps.pack.outputs.tag }}
  145. - name: Push tags
  146. run: git push --tags
  147. - name: Create Github Release
  148. uses: actions/github-script@v6
  149. env:
  150. PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
  151. with:
  152. script: await require('./scripts/release/workflow/github-release.js')({ github, context })
  153. merge:
  154. needs: state
  155. name: Create PR back to master
  156. permissions:
  157. contents: write
  158. pull-requests: write
  159. if: needs.state.outputs.merge == 'true'
  160. runs-on: ubuntu-latest
  161. steps:
  162. - uses: actions/checkout@v3
  163. with:
  164. fetch-depth: 0 # All branches
  165. - name: Set up environment
  166. uses: ./.github/actions/setup
  167. - run: bash scripts/git-user-config.sh
  168. - name: Create branch to merge
  169. run: bash scripts/release/workflow/prepare-release-merge.sh
  170. - name: Create PR back to master
  171. uses: actions/github-script@v6
  172. with:
  173. script: |
  174. await github.rest.pulls.create({
  175. owner: context.repo.owner,
  176. repo: context.repo.repo,
  177. head: 'merge/${{ github.ref_name }}',
  178. base: 'master',
  179. title: '${{ format('Merge {0} branch', github.ref_name) }}'
  180. });