Skip to content

Commit 3f9d057

Browse files
committed
Merge remote-tracking branch 'upstream/master' into dev
2 parents cb57392 + 92799e6 commit 3f9d057

File tree

1 file changed

+34
-40
lines changed

1 file changed

+34
-40
lines changed

.github/workflows/build-binaries.yml

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ on:
2121
target_branch:
2222
description: 'Branch to make a release of'
2323
required: true
24-
default: 'dev'
24+
default: 'master'
2525

2626
# Dynamic name for the run
2727
run-name: >
@@ -31,21 +31,23 @@ concurrency:
3131
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
3232
cancel-in-progress: true
3333

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-
3934
jobs:
4035
create_draft_release_if_needed:
4136
runs-on: ubuntu-latest
4237
env:
4338
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+
4443
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
4546
version_tag: ${{ steps.get_version.outputs.VERSION_TAG }}
4647
steps:
4748
- name: Checkout git repo
4849
uses: actions/checkout@v4
50+
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
4951
# We only need a few files in this run, no point cloning everything
5052
with:
5153
sparse-checkout: |
@@ -56,6 +58,8 @@ jobs:
5658
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
5759

5860
- 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' }}
5963
id: get_version
6064
run: |
6165
version=$(node -p "require('./package.json').version")
@@ -68,14 +72,14 @@ jobs:
6872
with:
6973
tag: v${{ steps.get_version.outputs.VERSION_TAG }}
7074
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
7276
bodyFile: ${{ env.SHOULD_PUBLISH_ALPHA == 'true' && 'build/release-notes-alpha.md' || 'build/release-notes.md' }}
7377
allowUpdates: true
78+
# updateOnlyUnreleased: true Not needed as we already have `skipIfReleaseExists`
7479
skipIfReleaseExists: true
80+
makeLatest: false
7581
omitBodyDuringUpdate: true
76-
omitDraftDuringUpdate: true
7782
omitNameDuringUpdate: true
78-
omitPrereleaseDuringUpdate: true
7983

8084
build_linux:
8185
runs-on: ubuntu-22.04
@@ -113,21 +117,20 @@ jobs:
113117
run: yarn test
114118

115119
- 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 == '' }}
118122
run: |
119123
sed -i 's/"target": "deb"/"target": "${{ matrix.pkg_to_build }}"/g' package.json && yarn build-release
120124
121125
- 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 == '' }}
124128
uses: ./actions/upload_prod_artefacts
125129
with:
126130
upload_prefix: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.pkg_to_build }}
127131

128132
- 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 != '' }}
131134
run: |
132135
sed -i 's/"target": "deb"/"target": "${{ matrix.pkg_to_build }}"/g' package.json && yarn build-release-publish
133136
@@ -136,14 +139,14 @@ jobs:
136139
# Note: The jobs are overwriting each other's latest-linux.yml.
137140
# So, we upload all of them as artifacts, and then merge them (see `post_build_linux`)
138141
# 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' }}
140143
shell: bash
141144
run: |
142145
mv dist/latest-linux.yml dist/latest-linux-${{ matrix.pkg_to_build }}-${{ github.sha }}.yml
143146
144147
- name: Upload release metadata
145148
# 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' }}
147150
uses: actions/upload-artifact@v4
148151
with:
149152
name: latest-linux-${{ matrix.pkg_to_build }}-${{ github.sha }}.yml
@@ -152,12 +155,11 @@ jobs:
152155
post_build_linux:
153156
needs: [create_draft_release_if_needed, build_linux]
154157
runs-on: ubuntu-22.04
158+
if: ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' }}
155159
env:
156160
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157161
steps:
158162
- 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' }}
161163
uses: actions/checkout@v4
162164
# We only need a few files in this run, no point cloning everything
163165
with:
@@ -168,32 +170,29 @@ jobs:
168170
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
169171

170172
- 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' }}
173173
uses: actions/download-artifact@v4
174174
with:
175175
pattern: latest-linux-*-${{ github.sha }}.yml
176176
path: dist
177177
merge-multiple: true
178178

179179
- 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' }}
182180
run: |
183181
./build/setup-release-combine.sh ${{ github.sha }} linux
184182
185183
- 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' }}
188184
uses: ncipollo/release-action@v1
189185
with:
186+
# the if at the job level checks that version_tag is not empty
190187
tag: v${{ needs.create_draft_release_if_needed.outputs.version_tag }}
191188
artifacts: 'dist/latest-linux.yml'
189+
draft: true # important to keep this, so we **NEVER** make a live release through the CI
192190
allowUpdates: true
193191
omitNameDuringUpdate: true
194192
omitBodyDuringUpdate: true
195193
replacesArtifacts: true
196194
updateOnlyUnreleased: true
195+
makeLatest: false
197196

198197
build_windows:
199198
runs-on: windows-2022
@@ -219,19 +218,18 @@ jobs:
219218

220219
- name: Make release build but do not publish
221220
# 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 == '' }}
223222
run: yarn build-release
224223

225224
- 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 == '' }}
228227
uses: ./actions/upload_prod_artefacts
229228
with:
230229
upload_prefix: ${{ runner.os }}-${{ runner.arch }}
231230

232231
- 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 != '' }}
235233
run: yarn build-release-publish # No other args needed for windows publish
236234

237235
# 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:
267265
uses: ./actions/make_release_build
268266
with:
269267
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 != ''}}
271269

272270
build_mac_x64:
273271
runs-on: macos-13
@@ -300,17 +298,16 @@ jobs:
300298
uses: ./actions/make_release_build
301299
with:
302300
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 != '' }}
304302

305303
post_build_mac:
306304
needs: [create_draft_release_if_needed, build_mac_arm64, build_mac_x64]
307305
runs-on: ubuntu-22.04
306+
if: ${{ needs.create_draft_release_if_needed.outputs.version_tag != '' }}
308307
env:
309308
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
310309
steps:
311310
- 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' }}
314311
uses: actions/checkout@v4
315312
# We only need a few files in this run, no point cloning everything
316313
with:
@@ -321,29 +318,26 @@ jobs:
321318
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
322319

323320
- 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' }}
326321
uses: actions/download-artifact@v4
327322
with:
328323
pattern: latest-mac-*-${{ github.sha }}.yml
329324
path: dist
330325
merge-multiple: true
331326

332327
- 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' }}
335328
run: |
336329
./build/setup-release-combine.sh ${{ github.sha }} mac
337330
338331
- 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' }}
341332
uses: ncipollo/release-action@v1
333+
# the if at the job level checks that version_tag is not empty
342334
with:
343335
tag: v${{ needs.create_draft_release_if_needed.outputs.version_tag }}
344336
artifacts: 'dist/latest-mac.yml'
337+
draft: true # important to keep this, so we **NEVER** make a live release through the CI
345338
allowUpdates: true
346339
omitNameDuringUpdate: true
347340
omitBodyDuringUpdate: true
348341
replacesArtifacts: true
349342
updateOnlyUnreleased: true
343+
makeLatest: false

0 commit comments

Comments
 (0)