Skip to content

Commit 4218d73

Browse files
committed
chore: allow to trigger draft release from workflow_dispatch
1 parent 3aef09e commit 4218d73

File tree

1 file changed

+59
-10
lines changed

1 file changed

+59
-10
lines changed

.github/workflows/build-binaries.yml

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,63 @@ on:
1616
- dev
1717
- 'release/**'
1818
- 'ci/**'
19+
workflow_dispatch:
20+
inputs:
21+
target_branch:
22+
description: 'Branch to make a release of'
23+
required: true
24+
default: 'dev'
1925

2026
concurrency:
2127
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
2228
cancel-in-progress: true
2329

2430
env:
2531
# we only want to publish on "push to master" or alpha releases. When we don't want to publish, we want to upload artefacts
26-
SHOULD_PUBLISH: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
27-
SHOULD_PUBLISH_ALPHA: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && contains(github.ref, '-alpha.') }}
32+
SHOULD_PUBLISH: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master'}}
33+
SHOULD_PUBLISH_ALPHA: ${{((github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && contains(github.ref, '-alpha.'))) || (github.event_name == 'workflow_dispatch') }}
2834

2935
jobs:
36+
create_draft_release_if_needed:
37+
runs-on: ubuntu-latest
38+
env:
39+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
outputs:
41+
version_tag: ${{ steps.get_version.outputs.VERSION_TAG }}
42+
steps:
43+
- name: Checkout git repo
44+
uses: actions/checkout@v4
45+
# We only need a few files in this run, no point cloning everything
46+
with:
47+
sparse-checkout: |
48+
package.json
49+
build/release-notes.md
50+
build/release-notes-alpha.md
51+
sparse-checkout-cone-mode: false
52+
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
53+
54+
- name: Get version tag from package.json
55+
id: get_version
56+
run: |
57+
version=$(node -p "require('./package.json').version")
58+
echo "VERSION_TAG=$version" >> "$GITHUB_OUTPUT"
59+
60+
- name: Create draft release
61+
# only run this on "push" to "master" or alpha releases
62+
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
63+
uses: ncipollo/release-action@v1
64+
with:
65+
tag: v${{ steps.get_version.outputs.VERSION_TAG }}
66+
name: 'Session ${{ steps.get_version.outputs.VERSION_TAG }}'
67+
draft: true
68+
bodyFile: ${{ env.SHOULD_PUBLISH_ALPHA == 'true' && 'build/release-notes-alpha.md' || 'build/release-notes.md' }}
69+
allowUpdates: true
70+
skipIfReleaseExists: true
71+
omitBodyDuringUpdate: true
72+
omitDraftDuringUpdate: true
73+
omitNameDuringUpdate: true
74+
omitPrereleaseDuringUpdate: true
75+
3076
build_linux:
3177
runs-on: ubuntu-22.04
3278
strategy:
@@ -42,6 +88,8 @@ jobs:
4288

4389
- name: Checkout git repo
4490
uses: actions/checkout@v4
91+
with:
92+
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
4593

4694
- name: Setup & Build
4795
uses: ./actions/setup_and_build
@@ -114,6 +162,7 @@ jobs:
114162
build/release-notes.md
115163
build/release-notes-alpha.md
116164
sparse-checkout-cone-mode: false
165+
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
117166

118167
- name: Get version tag from package.json
119168
id: get_version
@@ -163,6 +212,8 @@ jobs:
163212

164213
- name: Checkout git repo
165214
uses: actions/checkout@v4
215+
with:
216+
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
166217

167218
- name: Setup & Build
168219
uses: ./actions/setup_and_build
@@ -206,6 +257,8 @@ jobs:
206257

207258
- name: Checkout git repo
208259
uses: actions/checkout@v4
260+
with:
261+
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
209262

210263
- name: Setup & Build
211264
uses: ./actions/setup_and_build
@@ -236,6 +289,8 @@ jobs:
236289

237290
- name: Checkout git repo
238291
uses: actions/checkout@v4
292+
with:
293+
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
239294

240295
- name: Setup & Build
241296
uses: ./actions/setup_and_build
@@ -265,14 +320,8 @@ jobs:
265320
sparse-checkout: |
266321
package.json
267322
build/setup-release-combine.sh
268-
269-
- name: Get version tag from package.json
270-
id: get_version
271-
# only run this on "push" to "master" or alpha releases
272-
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
273-
run: |
274-
version=$(node -p "require('./package.json').version")
275-
echo "VERSION_TAG=$version" >> "$GITHUB_OUTPUT"
323+
sparse-checkout-cone-mode: false
324+
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
276325

277326
- name: Download release metadata
278327
# only run this on "push" to "master" or alpha releases

0 commit comments

Comments
 (0)