|
1 | 1 | # Release
|
2 | 2 | #
|
3 |
| -# Publish a GitHub release when a `release/*` branch is merged into `main` or on workflow dispatch. |
| 3 | +# Publish a GitHub release on release branch merge or workflow dispatch. |
4 | 4 | #
|
5 | 5 | # References:
|
6 | 6 | #
|
|
17 | 17 | # - https://github.com/actions/checkout
|
18 | 18 | # - https://github.com/bdougie/close-issues-based-on-label
|
19 | 19 | # - https://github.com/crazy-max/ghaction-import-gpg
|
20 |
| -# - https://github.com/dawidd6/action-delete-branch |
21 | 20 | # - https://github.com/flex-development/dist-tag-action
|
22 | 21 | # - https://github.com/hmarr/debug-action
|
23 | 22 | # - https://yarnpkg.com/cli/pack
|
|
33 | 32 | workflow_dispatch:
|
34 | 33 | inputs:
|
35 | 34 | sha:
|
36 |
| - description: pull request merge commit sha |
| 35 | + description: release commit sha |
37 | 36 | required: true
|
38 | 37 | type: string
|
| 38 | +env: |
| 39 | + REF: ${{ inputs.sha || github.event.pull_request.merge_commit_sha }} |
| 40 | + REF_NAME: ${{ format('main@{0}', inputs.sha || github.event.pull_request.merge_commit_sha) }} |
39 | 41 | jobs:
|
40 | 42 | preflight:
|
41 | 43 | if: |
|
42 | 44 | (github.event.pull_request.merged && startsWith(github.head_ref, 'release/')) ||
|
43 |
| - github.event_name == 'workflow_dispatch' |
| 45 | + (github.event_name == 'workflow_dispatch' && github.ref_name == 'main') |
44 | 46 | runs-on: ubuntu-latest
|
45 | 47 | permissions:
|
46 | 48 | contents: read
|
47 |
| - env: |
48 |
| - REF: ${{ inputs.sha || github.head_ref }} |
49 | 49 | outputs:
|
50 | 50 | prerelease: ${{ steps.dist-tag.outputs.prerelease }}
|
51 | 51 | tag: ${{ steps.tag.outputs.result }}
|
|
55 | 55 | name: Print environment variables and event payload
|
56 | 56 | uses: hmarr/debug-action@v2.1.0
|
57 | 57 | - id: checkout
|
58 |
| - name: Checkout ${{ env.REF }} |
| 58 | + name: Checkout ${{ env.REF_NAME }} |
59 | 59 | uses: actions/checkout@v3.5.0
|
60 | 60 | with:
|
61 | 61 | ref: ${{ env.REF }}
|
@@ -92,11 +92,10 @@ jobs:
|
92 | 92 | NODE_NO_WARNINGS: 1
|
93 | 93 | NOTES_FILE: ./RELEASE_NOTES.md
|
94 | 94 | PRERELEASE: ${{ needs.preflight.outputs.prerelease }}
|
95 |
| - REF: ${{ inputs.sha || github.event.pull_request.merge_commit_sha }} |
96 | 95 | TAG: ${{ needs.preflight.outputs.tag }}
|
97 | 96 | steps:
|
98 | 97 | - id: checkout
|
99 |
| - name: Checkout ${{ env.REF }} |
| 98 | + name: Checkout ${{ env.REF_NAME }} |
100 | 99 | uses: actions/checkout@v3.5.0
|
101 | 100 | with:
|
102 | 101 | fetch-depth: 0
|
@@ -143,25 +142,8 @@ jobs:
|
143 | 142 | env:
|
144 | 143 | GITHUB_TOKEN: ${{ secrets.PAT_REPO }}
|
145 | 144 | run: gh release create $TAG *.tgz -t=$TAG -p=$PRERELEASE -F=$NOTES_FILE
|
146 |
| - cleanup: |
147 |
| - needs: |
148 |
| - - preflight |
149 |
| - - publish |
150 |
| - permissions: |
151 |
| - contents: write |
152 |
| - issues: write |
153 |
| - runs-on: ubuntu-latest |
154 |
| - steps: |
155 |
| - - id: close-released-issues |
| 145 | + - id: close-issues |
156 | 146 | name: Close released issues
|
157 | 147 | uses: bdougie/close-issues-based-on-label@master
|
158 | 148 | env:
|
159 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
160 |
| - LABEL: status:${{ (needs.preflight.outputs.prerelease && 'prereleased') || 'released' }} |
161 |
| - - id: delete-release-branch |
162 |
| - name: Delete release/${{ needs.preflight.outputs.version }} |
163 |
| - uses: dawidd6/action-delete-branch@v3.1.0 |
164 |
| - with: |
165 |
| - branches: release/ |
166 |
| - soft_fail: true |
167 |
| - suffix: ${{ needs.preflight.outputs.version }} |
| 149 | + LABEL: status:${{ needs.preflight.outputs.prerelease && 'prereleased' || 'released' }} |
0 commit comments