Skip to content

Commit ff0b170

Browse files
authored
Merge pull request #1550 from session-foundation/fix-workflow-draft-single
chore: make drafting release a single step before all jobs start
2 parents b15b2c2 + 7919d6d commit ff0b170

File tree

1 file changed

+46
-28
lines changed

1 file changed

+46
-28
lines changed

.github/workflows/build-binaries.yml

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,44 @@ env:
2727
SHOULD_PUBLISH_ALPHA: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && contains(github.ref, '-alpha.') }}
2828

2929
jobs:
30+
create_draft_release:
31+
runs-on: ubuntu-latest
32+
env:
33+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
outputs:
35+
version_tag: ${{ steps.get_version.outputs.VERSION_TAG }}
36+
steps:
37+
- name: Checkout git repo
38+
# only run this on "push" to "master" or alpha releases
39+
uses: actions/checkout@v4
40+
# We only need a few files in this run, no point cloning everything
41+
with:
42+
sparse-checkout: |
43+
package.json
44+
build/release-notes.md
45+
build/release-notes-alpha.md
46+
sparse-checkout-cone-mode: false
47+
48+
- name: Get version tag from package.json
49+
id: get_version
50+
run: |
51+
version=$(node -p "require('./package.json').version")
52+
echo "VERSION_TAG=$version" >> "$GITHUB_OUTPUT"
53+
54+
- name: Create draft release
55+
# only run this on "push" to "master" or alpha releases
56+
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
57+
uses: ncipollo/release-action@v1
58+
with:
59+
tag: v${{ steps.get_version.outputs.VERSION_TAG }}
60+
name: 'Session ${{ steps.get_version.outputs.VERSION_TAG }}'
61+
draft: true
62+
bodyFile: ${{ env.SHOULD_PUBLISH_ALPHA == 'true' && 'build/release-notes-alpha.md' || 'build/release-notes.md' }}
63+
allowUpdates: true
64+
3065
build_linux:
3166
runs-on: ubuntu-22.04
67+
needs: [create_draft_release]
3268
strategy:
3369
fail-fast: false
3470
matrix:
@@ -111,18 +147,8 @@ jobs:
111147
sparse-checkout: |
112148
package.json
113149
build/setup-release-combine.sh
114-
build/release-notes.md
115-
build/release-notes-alpha.md
116150
sparse-checkout-cone-mode: false
117151

118-
- name: Get version tag from package.json
119-
id: get_version
120-
# only run this on "push" to "master" or alpha releases
121-
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
122-
run: |
123-
version=$(node -p "require('./package.json').version")
124-
echo "VERSION_TAG=$version" >> "$GITHUB_OUTPUT"
125-
126152
- name: Download release metadata
127153
# only run this on "push" to "master" or alpha releases
128154
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
@@ -143,10 +169,7 @@ jobs:
143169
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
144170
uses: ncipollo/release-action@v1
145171
with:
146-
tag: v${{ steps.get_version.outputs.VERSION_TAG }}
147-
name: 'Session ${{ steps.get_version.outputs.VERSION_TAG }}'
148-
draft: true
149-
bodyFile: ${{ env.SHOULD_PUBLISH_ALPHA == 'true' && 'build/release-notes-alpha.md' || 'build/release-notes.md' }}
172+
tag: v${{ needs.create_draft_release.outputs.version_tag }}
150173
artifacts: 'dist/latest-linux.yml'
151174
allowUpdates: true
152175
omitNameDuringUpdate: true
@@ -156,6 +179,7 @@ jobs:
156179

157180
build_windows:
158181
runs-on: windows-2022
182+
needs: [create_draft_release]
159183
env:
160184
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
161185
steps:
@@ -193,6 +217,7 @@ jobs:
193217
# 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
194218
# NOTE x64 builds made on an arm64 host will not bundle the native modules correctly https://github.com/electron-userland/electron-builder/issues/8646
195219
build_mac_arm64:
220+
needs: [create_draft_release]
196221
runs-on: macos-14
197222
env:
198223
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -224,6 +249,7 @@ jobs:
224249

225250
build_mac_x64:
226251
runs-on: macos-13
252+
needs: [create_draft_release]
227253
env:
228254
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
229255
MAC_CERTIFICATE: ${{ secrets.MAC_CERTIFICATE }}
@@ -255,24 +281,19 @@ jobs:
255281
post_build_mac:
256282
needs: [build_mac_arm64, build_mac_x64]
257283
runs-on: ubuntu-22.04
284+
env:
285+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
258286
steps:
259287
- name: Checkout git repo
260288
# only run this on "push" to "master" or alpha releases
261289
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
262290
uses: actions/checkout@v4
263-
# We only need the package.json file in this run (to extract the version being built)
291+
# We only need a few files in this run, no point cloning everything
264292
with:
265293
sparse-checkout: |
266294
package.json
267295
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"
296+
sparse-checkout-cone-mode: false
276297

277298
- name: Download release metadata
278299
# only run this on "push" to "master" or alpha releases
@@ -294,13 +315,10 @@ jobs:
294315
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
295316
uses: ncipollo/release-action@v1
296317
with:
297-
tag: v${{ steps.get_version.outputs.VERSION_TAG }}
298-
name: 'Session ${{ steps.get_version.outputs.VERSION_TAG }}'
299-
draft: true
300-
bodyFile: ${{ env.SHOULD_PUBLISH_ALPHA == 'true' && 'build/release-notes-alpha.md' || 'build/release-notes.md' }}
318+
tag: v${{ needs.create_draft_release.outputs.version_tag }}
301319
artifacts: 'dist/latest-mac.yml'
302320
allowUpdates: true
303-
omitBodyDuringUpdate: true
304321
omitNameDuringUpdate: true
322+
omitBodyDuringUpdate: true
305323
replacesArtifacts: true
306324
updateOnlyUnreleased: true

0 commit comments

Comments
 (0)