21
21
target_branch :
22
22
description : ' Branch to make a release of'
23
23
required : true
24
- default : ' dev '
24
+ default : ' master '
25
25
26
26
# Dynamic name for the run
27
27
run-name : >
@@ -31,21 +31,23 @@ concurrency:
31
31
group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
32
32
cancel-in-progress : true
33
33
34
- env :
35
- # we only want to publish on "push to master" or alpha releases. When we don't want to publish, we want to upload artefacts
36
- SHOULD_PUBLISH : ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
37
- SHOULD_PUBLISH_ALPHA : ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && contains(github.ref, '-alpha.') }}
38
-
39
34
jobs :
40
35
create_draft_release_if_needed :
41
36
runs-on : ubuntu-latest
42
37
env :
43
38
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
39
+ # we only want to publish on "push to master" or alpha releases. When we don't want to publish, we want to upload artefacts
40
+ SHOULD_PUBLISH : ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
41
+ SHOULD_PUBLISH_ALPHA : ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && contains(github.ref, '-alpha.') }}
42
+
44
43
outputs :
44
+ # Note: It is very important to only set this when we want to do a release,
45
+ # as this will be used in the others jobs to know if we need to make a release/upload artefacts
45
46
version_tag : ${{ steps.get_version.outputs.VERSION_TAG }}
46
47
steps :
47
48
- name : Checkout git repo
48
49
uses : actions/checkout@v4
50
+ if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
49
51
# We only need a few files in this run, no point cloning everything
50
52
with :
51
53
sparse-checkout : |
56
58
ref : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
57
59
58
60
- name : Get version tag from package.json
61
+ # Make sure to skip this step if we do not want to make a release, as the other jobs will otherwise create a release.
62
+ if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
59
63
id : get_version
60
64
run : |
61
65
version=$(node -p "require('./package.json').version")
@@ -68,14 +72,14 @@ jobs:
68
72
with :
69
73
tag : v${{ steps.get_version.outputs.VERSION_TAG }}
70
74
name : ' Session ${{ steps.get_version.outputs.VERSION_TAG }}'
71
- draft : true
75
+ draft : true # important to keep this, so we **NEVER** make a live release through the CI
72
76
bodyFile : ${{ env.SHOULD_PUBLISH_ALPHA == 'true' && 'build/release-notes-alpha.md' || 'build/release-notes.md' }}
73
77
allowUpdates : true
78
+ # updateOnlyUnreleased: true Not needed as we already have `skipIfReleaseExists`
74
79
skipIfReleaseExists : true
80
+ makeLatest : false
75
81
omitBodyDuringUpdate : true
76
- omitDraftDuringUpdate : true
77
82
omitNameDuringUpdate : true
78
- omitPrereleaseDuringUpdate : true
79
83
80
84
build_linux :
81
85
runs-on : ubuntu-22.04
@@ -113,21 +117,20 @@ jobs:
113
117
run : yarn test
114
118
115
119
- name : Make release build but do not publish ${{ matrix.pkg_to_build }}
116
- # always run this, except on "push" to "master" or alpha releases
117
- if : ${{ env.SHOULD_PUBLISH == 'false' && env.SHOULD_PUBLISH_ALPHA == 'false ' }}
120
+ # we do want this part to run only when version_tag is unset (i.e. we are not making a release)
121
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag == '' }}
118
122
run : |
119
123
sed -i 's/"target": "deb"/"target": "${{ matrix.pkg_to_build }}"/g' package.json && yarn build-release
120
124
121
125
- name : Upload artefacts ${{ matrix.pkg_to_build }}
122
- # always run this, except on "push" to "master" or alpha releases
123
- if : ${{ env.SHOULD_PUBLISH == 'false' && env.SHOULD_PUBLISH_ALPHA == 'false ' }}
126
+ # we do want this part to run only when version_tag is unset (i.e. we are not making a release)
127
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag == '' }}
124
128
uses : ./actions/upload_prod_artefacts
125
129
with :
126
130
upload_prefix : ${{ runner.os }}-${{ runner.arch }}-${{ matrix.pkg_to_build }}
127
131
128
132
- name : Make release build & publish ${{ matrix.pkg_to_build }}
129
- # only run this on "push" to "master" or alpha releases
130
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
133
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' }}
131
134
run : |
132
135
sed -i 's/"target": "deb"/"target": "${{ matrix.pkg_to_build }}"/g' package.json && yarn build-release-publish
133
136
@@ -136,14 +139,14 @@ jobs:
136
139
# Note: The jobs are overwriting each other's latest-linux.yml.
137
140
# So, we upload all of them as artifacts, and then merge them (see `post_build_linux`)
138
141
# note: freebsd does not generate a latest-linux.yml file so we exclude it
139
- if : ${{ (env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true') && matrix.pkg_to_build != 'freebsd' }}
142
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' && matrix.pkg_to_build != 'freebsd' }}
140
143
shell : bash
141
144
run : |
142
145
mv dist/latest-linux.yml dist/latest-linux-${{ matrix.pkg_to_build }}-${{ github.sha }}.yml
143
146
144
147
- name : Upload release metadata
145
148
# only run this on "push" to "master" or alpha releases
146
- if : ${{ (env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true') && matrix.pkg_to_build != 'freebsd' }}
149
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' && matrix.pkg_to_build != 'freebsd' }}
147
150
uses : actions/upload-artifact@v4
148
151
with :
149
152
name : latest-linux-${{ matrix.pkg_to_build }}-${{ github.sha }}.yml
@@ -152,12 +155,11 @@ jobs:
152
155
post_build_linux :
153
156
needs : [create_draft_release_if_needed, build_linux]
154
157
runs-on : ubuntu-22.04
158
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' }}
155
159
env :
156
160
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
157
161
steps :
158
162
- name : Checkout git repo
159
- # only run this on "push" to "master" or alpha releases
160
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
161
163
uses : actions/checkout@v4
162
164
# We only need a few files in this run, no point cloning everything
163
165
with :
@@ -168,32 +170,29 @@ jobs:
168
170
ref : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
169
171
170
172
- name : Download release metadata
171
- # only run this on "push" to "master" or alpha releases
172
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
173
173
uses : actions/download-artifact@v4
174
174
with :
175
175
pattern : latest-linux-*-${{ github.sha }}.yml
176
176
path : dist
177
177
merge-multiple : true
178
178
179
179
- name : Combine release metadata
180
- # only run this on "push" to "master" or alpha releases
181
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
182
180
run : |
183
181
./build/setup-release-combine.sh ${{ github.sha }} linux
184
182
185
183
- name : Upload changes to draft release
186
- # only run this on "push" to "master" or alpha releases
187
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
188
184
uses : ncipollo/release-action@v1
189
185
with :
186
+ # the if at the job level checks that version_tag is not empty
190
187
tag : v${{ needs.create_draft_release_if_needed.outputs.version_tag }}
191
188
artifacts : ' dist/latest-linux.yml'
189
+ draft : true # important to keep this, so we **NEVER** make a live release through the CI
192
190
allowUpdates : true
193
191
omitNameDuringUpdate : true
194
192
omitBodyDuringUpdate : true
195
193
replacesArtifacts : true
196
194
updateOnlyUnreleased : true
195
+ makeLatest : false
197
196
198
197
build_windows :
199
198
runs-on : windows-2022
@@ -219,19 +218,18 @@ jobs:
219
218
220
219
- name : Make release build but do not publish
221
220
# always run this, except on "push" to "master" or alpha releases
222
- if : ${{ env.SHOULD_PUBLISH == 'false' && env.SHOULD_PUBLISH_ALPHA == 'false ' }}
221
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag == '' }}
223
222
run : yarn build-release
224
223
225
224
- name : Upload artefacts
226
- # always run this, except on "push" to "master" or alpha releases
227
- if : ${{ env.SHOULD_PUBLISH == 'false' && env.SHOULD_PUBLISH_ALPHA == 'false ' }}
225
+ # we do want this part to run only when version_tag is unset (i.e. we are not making a release)
226
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag == '' }}
228
227
uses : ./actions/upload_prod_artefacts
229
228
with :
230
229
upload_prefix : ${{ runner.os }}-${{ runner.arch }}
231
230
232
231
- name : Make release build & publish
233
- # only run this on "push" to "master" or alpha releases
234
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
232
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' }}
235
233
run : yarn build-release-publish # No other args needed for windows publish
236
234
237
235
# We want both arm64 and intel mac builds, and according to this https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources macos-14 and above is always arm64 and macos-13 is the last intel runner
@@ -267,7 +265,7 @@ jobs:
267
265
uses : ./actions/make_release_build
268
266
with :
269
267
architecture : arm64
270
- should_publish : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
268
+ should_publish : ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' }}
271
269
272
270
build_mac_x64 :
273
271
runs-on : macos-13
@@ -300,17 +298,16 @@ jobs:
300
298
uses : ./actions/make_release_build
301
299
with :
302
300
architecture : x64
303
- should_publish : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true ' }}
301
+ should_publish : ${{ needs.create_draft_release_if_needed.outputs.version_tag != ' ' }}
304
302
305
303
post_build_mac :
306
304
needs : [create_draft_release_if_needed, build_mac_arm64, build_mac_x64]
307
305
runs-on : ubuntu-22.04
306
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' }}
308
307
env :
309
308
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
310
309
steps :
311
310
- name : Checkout git repo
312
- # only run this on "push" to "master" or alpha releases
313
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
314
311
uses : actions/checkout@v4
315
312
# We only need a few files in this run, no point cloning everything
316
313
with :
@@ -321,29 +318,26 @@ jobs:
321
318
ref : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
322
319
323
320
- name : Download release metadata
324
- # only run this on "push" to "master" or alpha releases
325
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
326
321
uses : actions/download-artifact@v4
327
322
with :
328
323
pattern : latest-mac-*-${{ github.sha }}.yml
329
324
path : dist
330
325
merge-multiple : true
331
326
332
327
- name : Combine release metadata
333
- # only run this on "push" to "master" or alpha releases
334
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
335
328
run : |
336
329
./build/setup-release-combine.sh ${{ github.sha }} mac
337
330
338
331
- name : Upload changes to draft release
339
- # only run this on "push" to "master" or alpha releases
340
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
341
332
uses : ncipollo/release-action@v1
333
+ # the if at the job level checks that version_tag is not empty
342
334
with :
343
335
tag : v${{ needs.create_draft_release_if_needed.outputs.version_tag }}
344
336
artifacts : ' dist/latest-mac.yml'
337
+ draft : true # important to keep this, so we **NEVER** make a live release through the CI
345
338
allowUpdates : true
346
339
omitNameDuringUpdate : true
347
340
omitBodyDuringUpdate : true
348
341
replacesArtifacts : true
349
342
updateOnlyUnreleased : true
343
+ makeLatest : false
0 commit comments