Skip to content

Commit 0edd574

Browse files
committed
ci(workflows): [release] checkout release commit from main
- allows head branch to be auto-deleted after pr merge Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 5578022 commit 0edd574

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release
22
#
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.
44
#
55
# References:
66
#
@@ -17,7 +17,6 @@
1717
# - https://github.com/actions/checkout
1818
# - https://github.com/bdougie/close-issues-based-on-label
1919
# - https://github.com/crazy-max/ghaction-import-gpg
20-
# - https://github.com/dawidd6/action-delete-branch
2120
# - https://github.com/flex-development/dist-tag-action
2221
# - https://github.com/hmarr/debug-action
2322
# - https://yarnpkg.com/cli/pack
@@ -33,19 +32,20 @@ on:
3332
workflow_dispatch:
3433
inputs:
3534
sha:
36-
description: pull request merge commit sha
35+
description: release commit sha
3736
required: true
3837
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) }}
3941
jobs:
4042
preflight:
4143
if: |
4244
(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')
4446
runs-on: ubuntu-latest
4547
permissions:
4648
contents: read
47-
env:
48-
REF: ${{ inputs.sha || github.head_ref }}
4949
outputs:
5050
prerelease: ${{ steps.dist-tag.outputs.prerelease }}
5151
tag: ${{ steps.tag.outputs.result }}
@@ -55,7 +55,7 @@ jobs:
5555
name: Print environment variables and event payload
5656
uses: hmarr/debug-action@v2.1.0
5757
- id: checkout
58-
name: Checkout ${{ env.REF }}
58+
name: Checkout ${{ env.REF_NAME }}
5959
uses: actions/checkout@v3.5.0
6060
with:
6161
ref: ${{ env.REF }}
@@ -92,11 +92,10 @@ jobs:
9292
NODE_NO_WARNINGS: 1
9393
NOTES_FILE: ./RELEASE_NOTES.md
9494
PRERELEASE: ${{ needs.preflight.outputs.prerelease }}
95-
REF: ${{ inputs.sha || github.event.pull_request.merge_commit_sha }}
9695
TAG: ${{ needs.preflight.outputs.tag }}
9796
steps:
9897
- id: checkout
99-
name: Checkout ${{ env.REF }}
98+
name: Checkout ${{ env.REF_NAME }}
10099
uses: actions/checkout@v3.5.0
101100
with:
102101
fetch-depth: 0
@@ -143,25 +142,8 @@ jobs:
143142
env:
144143
GITHUB_TOKEN: ${{ secrets.PAT_REPO }}
145144
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
156146
name: Close released issues
157147
uses: bdougie/close-issues-based-on-label@master
158148
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

Comments
 (0)