Skip to content

Commit c7d163b

Browse files
committed
feat(ci): auto-tag and publish release notes on Release PR merge
When a release/* PR is merged to main: 1. Read version from apps/desktop/package.json 2. Push git tag (v0.1.8, etc.) 3. Create GitHub Release using PR body as release notes This completes the "merge Release PR = auto publish" flow described in the release process doc. The existing desktop-release.yml (triggered by tag push) then builds signed packages and uploads them to the release.
1 parent e5ada3f commit c7d163b

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Desktop Auto-Tag on Release PR Merge
2+
3+
# When a release/* PR is merged to main, automatically:
4+
# 1. Read the version from apps/desktop/package.json
5+
# 2. Push the git tag (v0.1.8, etc.)
6+
# 3. Create a GitHub Release using the PR body as release notes
7+
#
8+
# This bridges the gap between "merge Release PR" and "desktop-release.yml"
9+
# which triggers on tag push to build + sign + publish artifacts.
10+
11+
on:
12+
pull_request:
13+
types: [closed]
14+
branches: [main]
15+
16+
permissions:
17+
contents: write
18+
19+
jobs:
20+
auto-tag:
21+
# Only run when a release/* PR is merged (not just closed)
22+
if: >-
23+
github.event.pull_request.merged == true &&
24+
startsWith(github.event.pull_request.head.ref, 'release/')
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout merged commit
29+
uses: actions/checkout@v4
30+
with:
31+
ref: ${{ github.event.pull_request.merge_commit_sha }}
32+
fetch-depth: 0
33+
34+
- name: Read version from package.json
35+
id: version
36+
run: |
37+
set -euo pipefail
38+
version=$(node -e 'process.stdout.write(require("./apps/desktop/package.json").version)')
39+
tag="v${version}"
40+
41+
echo "version=$version" >> "$GITHUB_OUTPUT"
42+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
43+
echo "Detected version: $version → tag: $tag"
44+
45+
- name: Check if tag already exists
46+
id: check
47+
run: |
48+
if git rev-parse "${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
49+
echo "exists=true" >> "$GITHUB_OUTPUT"
50+
echo "Tag ${{ steps.version.outputs.tag }} already exists, skipping"
51+
else
52+
echo "exists=false" >> "$GITHUB_OUTPUT"
53+
fi
54+
55+
- name: Push tag
56+
if: steps.check.outputs.exists == 'false'
57+
run: |
58+
git config user.name "github-actions[bot]"
59+
git config user.email "github-actions[bot]@users.noreply.github.com"
60+
git tag "${{ steps.version.outputs.tag }}" "${{ github.event.pull_request.merge_commit_sha }}"
61+
git push origin "${{ steps.version.outputs.tag }}"
62+
echo "Pushed tag ${{ steps.version.outputs.tag }}"
63+
64+
- name: Create GitHub Release with PR body as release notes
65+
if: steps.check.outputs.exists == 'false'
66+
env:
67+
GH_TOKEN: ${{ github.token }}
68+
run: |
69+
set -euo pipefail
70+
71+
tag="${{ steps.version.outputs.tag }}"
72+
pr_number="${{ github.event.pull_request.number }}"
73+
74+
# Extract PR body (the release notes)
75+
pr_body=$(gh pr view "$pr_number" --json body --jq '.body')
76+
77+
# Create the release (draft: false so it publishes immediately)
78+
# desktop-release.yml will detect the tag and upload build artifacts
79+
gh release create "$tag" \
80+
--title "$tag" \
81+
--notes "$pr_body" \
82+
--target "${{ github.event.pull_request.merge_commit_sha }}"
83+
84+
echo "Created GitHub Release $tag with notes from PR #$pr_number"

0 commit comments

Comments
 (0)