Skip to content

Commit 866026f

Browse files
authored
Merge pull request #1571 from session-foundation/chore/add-workflow-dispatch-build
chore: allow to trigger draft release from workflow_dispatch
2 parents d190252 + 4e8ea0c commit 866026f

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

.github/workflows/build-binaries.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ on:
2323
required: true
2424
default: 'dev'
2525

26+
# Dynamic name for the run
27+
run-name: >
28+
Session Desktop ${{ github.event_name == 'workflow_dispatch' && format('(manual run on {0})', github.event.inputs.target_branch) || format('(push)', github.event.pull_request.number || github.ref) }}
29+
2630
concurrency:
2731
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
2832
cancel-in-progress: true
2933

3034
env:
3135
# we only want to publish on "push to master" or alpha releases. When we don't want to publish, we want to upload artefacts
3236
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') }}
37+
SHOULD_PUBLISH_ALPHA: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') && contains(github.ref, '-alpha.') }}
3438

3539
jobs:
3640
create_draft_release_if_needed:
@@ -75,6 +79,7 @@ jobs:
7579

7680
build_linux:
7781
runs-on: ubuntu-22.04
82+
needs: [create_draft_release_if_needed]
7883
strategy:
7984
fail-fast: false
8085
matrix:
@@ -159,19 +164,9 @@ jobs:
159164
sparse-checkout: |
160165
package.json
161166
build/setup-release-combine.sh
162-
build/release-notes.md
163-
build/release-notes-alpha.md
164167
sparse-checkout-cone-mode: false
165168
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch || github.ref }}
166169

167-
- name: Get version tag from package.json
168-
id: get_version
169-
# only run this on "push" to "master" or alpha releases
170-
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
171-
run: |
172-
version=$(node -p "require('./package.json').version")
173-
echo "VERSION_TAG=$version" >> "$GITHUB_OUTPUT"
174-
175170
- name: Download release metadata
176171
# only run this on "push" to "master" or alpha releases
177172
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
@@ -192,10 +187,7 @@ jobs:
192187
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
193188
uses: ncipollo/release-action@v1
194189
with:
195-
tag: v${{ steps.get_version.outputs.VERSION_TAG }}
196-
name: 'Session ${{ steps.get_version.outputs.VERSION_TAG }}'
197-
draft: true
198-
bodyFile: ${{ env.SHOULD_PUBLISH_ALPHA == 'true' && 'build/release-notes-alpha.md' || 'build/release-notes.md' }}
190+
tag: v${{ needs.create_draft_release_if_needed.outputs.version_tag }}
199191
artifacts: 'dist/latest-linux.yml'
200192
allowUpdates: true
201193
omitNameDuringUpdate: true
@@ -205,6 +197,7 @@ jobs:
205197

206198
build_windows:
207199
runs-on: windows-2022
200+
needs: [create_draft_release_if_needed]
208201
env:
209202
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
210203
steps:
@@ -244,6 +237,7 @@ jobs:
244237
# 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
245238
# NOTE x64 builds made on an arm64 host will not bundle the native modules correctly https://github.com/electron-userland/electron-builder/issues/8646
246239
build_mac_arm64:
240+
needs: [create_draft_release_if_needed]
247241
runs-on: macos-14
248242
env:
249243
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -277,6 +271,7 @@ jobs:
277271

278272
build_mac_x64:
279273
runs-on: macos-13
274+
needs: [create_draft_release_if_needed]
280275
env:
281276
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
282277
MAC_CERTIFICATE: ${{ secrets.MAC_CERTIFICATE }}
@@ -310,12 +305,14 @@ jobs:
310305
post_build_mac:
311306
needs: [build_mac_arm64, build_mac_x64]
312307
runs-on: ubuntu-22.04
308+
env:
309+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
313310
steps:
314311
- name: Checkout git repo
315312
# only run this on "push" to "master" or alpha releases
316313
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
317314
uses: actions/checkout@v4
318-
# We only need the package.json file in this run (to extract the version being built)
315+
# We only need a few files in this run, no point cloning everything
319316
with:
320317
sparse-checkout: |
321318
package.json
@@ -343,10 +340,7 @@ jobs:
343340
if: ${{ env.SHOULD_PUBLISH == 'true' || env.SHOULD_PUBLISH_ALPHA == 'true' }}
344341
uses: ncipollo/release-action@v1
345342
with:
346-
tag: v${{ steps.get_version.outputs.VERSION_TAG }}
347-
name: 'Session ${{ steps.get_version.outputs.VERSION_TAG }}'
348-
draft: true
349-
bodyFile: ${{ env.SHOULD_PUBLISH_ALPHA == 'true' && 'build/release-notes-alpha.md' || 'build/release-notes.md' }}
343+
tag: v${{ needs.create_draft_release_if_needed.outputs.version_tag }}
350344
artifacts: 'dist/latest-mac.yml'
351345
allowUpdates: true
352346
omitBodyDuringUpdate: true

0 commit comments

Comments
 (0)