Skip to content

Commit 2410758

Browse files
committed
gate release publish to tags, dry-run on branch
1 parent dd8572f commit 2410758

1 file changed

Lines changed: 75 additions & 15 deletions

File tree

.github/workflows/code-release.yml

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ on:
44
push:
55
tags:
66
- "v*"
7+
branches:
8+
# Temporary: full pre-merge dry run of the release pipeline on this branch.
9+
# Builds, signs and verifies every platform but does NOT create or publish a
10+
# GitHub release (all release steps are gated to tags below). Remove this
11+
# entry before merging.
12+
- refactor/electron-vite
13+
workflow_dispatch:
714

815
concurrency:
9-
group: code-release
10-
cancel-in-progress: false
16+
# Per-ref so a branch dry run never serializes behind or cancels a tag release.
17+
group: code-release-${{ github.ref }}
18+
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/v') }}
1119

1220
jobs:
1321
prepare-release:
@@ -29,6 +37,7 @@ jobs:
2937
echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
3038
3139
- name: Create draft release if absent
40+
if: startsWith(github.ref, 'refs/tags/v')
3241
env:
3342
GH_TOKEN: ${{ steps.app-token.outputs.token }}
3443
APP_VERSION: ${{ steps.version.outputs.version }}
@@ -97,12 +106,16 @@ jobs:
97106
node-version: 22
98107
cache: "pnpm"
99108

100-
- name: Extract version from tag
109+
- name: Resolve version
101110
id: version
102111
run: |
103-
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
104-
echo "Version: $TAG_VERSION"
105-
echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
112+
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
113+
VERSION="${GITHUB_REF#refs/tags/v}"
114+
else
115+
VERSION="$(jq -r .version apps/code/package.json)"
116+
fi
117+
echo "Version: $VERSION"
118+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
106119
107120
- name: Set version in package.json
108121
env:
@@ -205,6 +218,7 @@ jobs:
205218
retention-days: 7
206219

207220
- name: Upload release artifacts
221+
if: startsWith(github.ref, 'refs/tags/v')
208222
env:
209223
GH_TOKEN: ${{ steps.app-token.outputs.token }}
210224
APP_VERSION: ${{ steps.version.outputs.version }}
@@ -214,6 +228,18 @@ jobs:
214228
apps/code/out/*-mac.zip \
215229
apps/code/out/*.blockmap
216230
231+
- name: Upload build artifacts (dry run)
232+
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
233+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
234+
with:
235+
name: code-macos-${{ matrix.arch }}
236+
path: |
237+
apps/code/out/*.dmg
238+
apps/code/out/*-mac.zip
239+
apps/code/out/*.blockmap
240+
apps/code/out/latest-mac.yml
241+
retention-days: 7
242+
217243
- name: Upload mac manifest artifact
218244
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
219245
with:
@@ -256,15 +282,19 @@ jobs:
256282
node-version: 22
257283
cache: "pnpm"
258284

259-
- name: Extract version from tag
285+
- name: Resolve version
260286
id: version
261287
shell: pwsh
262288
env:
263289
GITHUB_REF: ${{ github.ref }}
264290
run: |
265-
$tagVersion = "$env:GITHUB_REF" -replace "refs/tags/v", ""
266-
echo "Version: $tagVersion"
267-
echo "version=$tagVersion" >> $env:GITHUB_OUTPUT
291+
if ("$env:GITHUB_REF" -like "refs/tags/v*") {
292+
$version = "$env:GITHUB_REF" -replace "refs/tags/v", ""
293+
} else {
294+
$version = (Get-Content apps/code/package.json -Raw | ConvertFrom-Json).version
295+
}
296+
echo "Version: $version"
297+
echo "version=$version" >> $env:GITHUB_OUTPUT
268298
269299
- name: Set version in package.json
270300
shell: pwsh
@@ -306,6 +336,7 @@ jobs:
306336
pnpm exec electron-builder build --win --x64 --publish never --config electron-builder.ts
307337
308338
- name: Upload release artifacts
339+
if: startsWith(github.ref, 'refs/tags/v')
309340
shell: pwsh
310341
env:
311342
GH_TOKEN: ${{ steps.app-token.outputs.token }}
@@ -327,6 +358,19 @@ jobs:
327358
$files = $items | Select-Object -ExpandProperty FullName
328359
gh release upload "v$env:APP_VERSION" --repo PostHog/code --clobber @files
329360
361+
- name: Upload build artifacts (dry run)
362+
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
363+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
364+
with:
365+
name: code-windows
366+
path: |
367+
apps/code/out/*.exe
368+
apps/code/out/latest.yml
369+
apps/code/out/*.blockmap
370+
apps/code/out/squirrel-windows/**
371+
retention-days: 7
372+
if-no-files-found: ignore
373+
330374
publish-linux:
331375
needs: [prepare-release]
332376
strategy:
@@ -378,12 +422,16 @@ jobs:
378422
node-version: 22
379423
cache: "pnpm"
380424

381-
- name: Extract version from tag
425+
- name: Resolve version
382426
id: version
383427
run: |
384-
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
385-
echo "Version: $TAG_VERSION"
386-
echo "version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
428+
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
429+
VERSION="${GITHUB_REF#refs/tags/v}"
430+
else
431+
VERSION="$(jq -r .version apps/code/package.json)"
432+
fi
433+
echo "Version: $VERSION"
434+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
387435
388436
- name: Set version in package.json
389437
env:
@@ -426,6 +474,7 @@ jobs:
426474
fi
427475
428476
- name: Upload release artifacts
477+
if: startsWith(github.ref, 'refs/tags/v')
429478
env:
430479
GH_TOKEN: ${{ steps.app-token.outputs.token }}
431480
APP_VERSION: ${{ steps.version.outputs.version }}
@@ -435,12 +484,23 @@ jobs:
435484
apps/code/out/*.deb \
436485
apps/code/out/*.rpm
437486
487+
- name: Upload build artifacts (dry run)
488+
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
489+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
490+
with:
491+
name: code-linux-${{ matrix.arch }}
492+
path: |
493+
apps/code/out/*.AppImage
494+
apps/code/out/*.deb
495+
apps/code/out/*.rpm
496+
retention-days: 7
497+
438498
finalize-release:
439499
needs: [publish-macos, publish-windows, publish-linux]
440500
# macOS is the primary platform: publish the release as long as macOS built
441501
# successfully, even if Windows or Linux failed. always() is required so this
442502
# job isn't skipped when a non-macOS publish job fails.
443-
if: always() && needs.publish-macos.result == 'success'
503+
if: always() && needs.publish-macos.result == 'success' && startsWith(github.ref, 'refs/tags/v')
444504
runs-on: ubuntu-latest
445505
permissions:
446506
contents: write

0 commit comments

Comments
 (0)