Skip to content

Commit 5b586ae

Browse files
beautyfreeclaude
andcommitted
ci: trigger release.yml on release creation so drafts build automatically
release-please creates the GitHub Release as a draft, and draft releases don't spawn a git tag until they're published — which meant the tag-push trigger never fired and no build ran. Users had to manually git-push-tag after every release to get binaries. Add a second trigger `release: [created]` that fires when release-please drops its draft. checkout now uses release.target_commitish as the ref (draft releases don't have tags yet to check out). All downstream steps resolve the tag name via github.event.release.tag_name with fallback to github.ref_name so tag-push remains as a maintainer-rescue path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ba9ae68 commit 5b586ae

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
name: Release
22

3-
# Triggered by pushing a tag like v0.2.0. release-please (see
4-
# .github/workflows/release-please.yml) creates the GitHub Release + tag when
5-
# its "Release PR" is merged; this workflow then builds the Electron app
6-
# natively on each OS (electron-builder + node-gyp native modules don't
7-
# cross-compile cleanly) and uploads every artifact to that same release.
8-
# electron-updater reads `latest-{mac,linux,win}.yml` from the same release
9-
# to drive auto-updates in production.
10-
3+
# Two triggers that cover the two ways a release lands here:
4+
#
5+
# 1. `release: [created]` — fires when release-please creates the draft
6+
# release after its PR is merged. This is the normal path. Draft
7+
# releases don't create a git tag until they're published, so tag
8+
# push alone wouldn't fire (see commit 4032f11 for the draft switch).
9+
#
10+
# 2. `push: tags: v*` — fallback for when a maintainer hand-creates a
11+
# tag locally (e.g. to rebuild a release whose assets got corrupted).
12+
# Also covers anyone using a PAT-based release-please flow where the
13+
# tag push genuinely does trigger workflows.
14+
#
15+
# Both paths resolve the tag/release via TAG_NAME below so the downstream
16+
# softprops/gh-release steps don't care which trigger fired.
1117
on:
18+
release:
19+
types: [created]
1220
push:
1321
tags:
1422
- "v*"
@@ -17,7 +25,9 @@ permissions:
1725
contents: write
1826

1927
concurrency:
20-
group: ${{ github.workflow }}-${{ github.ref }}
28+
# Deduplicate by tag so the `release: created` + late `push: tags` never
29+
# run simultaneously for the same version.
30+
group: ${{ github.workflow }}-${{ github.event.release.tag_name || github.ref }}
2131
cancel-in-progress: false
2232

2333
jobs:
@@ -39,6 +49,12 @@ jobs:
3949
script: dist:linux
4050
steps:
4151
- uses: actions/checkout@v5
52+
with:
53+
# On `release: created` for a draft, there's no git tag yet — use
54+
# the release's target commit sha. On tag push, github.ref resolves
55+
# to the tag itself (checkout picks that up by default).
56+
ref: ${{ github.event.release.target_commitish || github.ref }}
57+
4258

4359
- uses: oven-sh/setup-bun@v2
4460
with:
@@ -130,7 +146,7 @@ jobs:
130146
- name: Upload build outputs to Release
131147
uses: softprops/action-gh-release@v2
132148
with:
133-
tag_name: ${{ github.ref_name }}
149+
tag_name: ${{ github.event.release.tag_name || github.ref_name }}
134150
# release-please creates the Release as a draft (see config). We
135151
# keep it a draft here too so softprops doesn't accidentally flip
136152
# it to published — the final publish-release job does that after
@@ -168,6 +184,6 @@ jobs:
168184
env:
169185
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170186
run: |
171-
gh release edit "${{ github.ref_name }}" \
187+
gh release edit "${{ github.event.release.tag_name || github.ref_name }}" \
172188
--repo "${{ github.repository }}" \
173189
--draft=false

0 commit comments

Comments
 (0)