@@ -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")
@@ -71,11 +75,11 @@ jobs:
71
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,28 +139,27 @@ 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
150
153
path : dist/latest-linux-${{ matrix.pkg_to_build }}-${{ github.sha }}.yml
151
154
152
155
post_build_linux :
153
- needs : [build_linux]
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,25 +170,20 @@ 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'
192
189
draft : true # important to keep this, so we **NEVER** make a live release through the CI
@@ -195,6 +192,7 @@ jobs:
195
192
omitBodyDuringUpdate : true
196
193
replacesArtifacts : true
197
194
updateOnlyUnreleased : true
195
+ makeLatest : false
198
196
199
197
build_windows :
200
198
runs-on : windows-2022
@@ -220,19 +218,18 @@ jobs:
220
218
221
219
- name : Make release build but do not publish
222
220
# always run this, except on "push" to "master" or alpha releases
223
- if : ${{ env.SHOULD_PUBLISH == 'false' && env.SHOULD_PUBLISH_ALPHA == 'false ' }}
221
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag != ' ' }}
224
222
run : yarn build-release
225
223
226
224
- name : Upload artefacts
227
- # always run this, except on "push" to "master" or alpha releases
228
- 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 == '' }}
229
227
uses : ./actions/upload_prod_artefacts
230
228
with :
231
229
upload_prefix : ${{ runner.os }}-${{ runner.arch }}
232
230
233
231
- name : Make release build & publish
234
- # only run this on "push" to "master" or alpha releases
235
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
232
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' }}
236
233
run : yarn build-release-publish # No other args needed for windows publish
237
234
238
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
@@ -268,7 +265,7 @@ jobs:
268
265
uses : ./actions/make_release_build
269
266
with :
270
267
architecture : arm64
271
- should_publish : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
268
+ should_publish : ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' }}
272
269
273
270
build_mac_x64 :
274
271
runs-on : macos-13
@@ -301,17 +298,16 @@ jobs:
301
298
uses : ./actions/make_release_build
302
299
with :
303
300
architecture : x64
304
- should_publish : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true ' }}
301
+ should_publish : ${{ needs.create_draft_release_if_needed.outputs.version_tag != ' ' }}
305
302
306
303
post_build_mac :
307
- needs : [build_mac_arm64, build_mac_x64]
304
+ needs : [create_draft_release_if_needed, build_mac_arm64, build_mac_x64]
308
305
runs-on : ubuntu-22.04
306
+ if : ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' }}
309
307
env :
310
308
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
311
309
steps :
312
310
- name : Checkout git repo
313
- # only run this on "push" to "master" or alpha releases
314
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
315
311
uses : actions/checkout@v4
316
312
# We only need a few files in this run, no point cloning everything
317
313
with :
@@ -322,24 +318,19 @@ jobs:
322
318
ref : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
323
319
324
320
- name : Download release metadata
325
- # only run this on "push" to "master" or alpha releases
326
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
327
321
uses : actions/download-artifact@v4
328
322
with :
329
323
pattern : latest-mac-*-${{ github.sha }}.yml
330
324
path : dist
331
325
merge-multiple : true
332
326
333
327
- name : Combine release metadata
334
- # only run this on "push" to "master" or alpha releases
335
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
336
328
run : |
337
329
./build/setup-release-combine.sh ${{ github.sha }} mac
338
330
339
331
- name : Upload changes to draft release
340
- # only run this on "push" to "master" or alpha releases
341
- if : ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
342
332
uses : ncipollo/release-action@v1
333
+ # the if at the job level checks that version_tag is not empty
343
334
with :
344
335
tag : v${{ needs.create_draft_release_if_needed.outputs.version_tag }}
345
336
artifacts : ' dist/latest-mac.yml'
@@ -349,3 +340,4 @@ jobs:
349
340
omitNameDuringUpdate : true
350
341
replacesArtifacts : true
351
342
updateOnlyUnreleased : true
343
+ makeLatest : false
0 commit comments