-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (165 loc) · 5.93 KB
/
release.yml
File metadata and controls
186 lines (165 loc) · 5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Release (stable)
on:
workflow_dispatch:
inputs:
version:
description: "Release version (e.g. 1.0.1). If empty, master's package.json is used."
required: false
type: string
default: ""
dry_run:
description: "Dry run — skip tag push and build (for testing)"
required: false
type: boolean
default: false
permissions:
contents: write
jobs:
# ── Step 1: Resolve version, commit if needed, tag, push ─────────
prepare:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.resolve.outputs.tag }}
version: ${{ steps.resolve.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
ssh-key: ${{ secrets.RELEASE_DEPLOY_KEY }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Resolve version
id: resolve
run: |
INPUT_VERSION="${{ inputs.version }}"
PKG_VERSION=$(node -p "require('./package.json').version")
if [ -z "$INPUT_VERSION" ]; then
VERSION="$PKG_VERSION"
echo "Using master's package.json version: $VERSION"
else
VERSION="$INPUT_VERSION"
echo "Using workflow input version: $VERSION"
fi
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::Stable version must be plain semver (X.Y.Z), got '$VERSION'."
exit 1
fi
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "::error::Tag v$VERSION already exists"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
- name: Bump package.json if needed
run: |
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const next = '${{ steps.resolve.outputs.version }}';
if (pkg.version !== next) {
pkg.version = next;
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
console.log('Updated package.json to ' + next);
} else {
console.log('package.json already at ' + next + '; no bump needed.');
}
"
- name: Commit and tag
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add package.json
if git diff --cached --quiet; then
echo "No package.json changes; tagging HEAD as-is."
else
git commit -m "release: ${{ steps.resolve.outputs.tag }}"
fi
git tag "${{ steps.resolve.outputs.tag }}"
- name: Push commit and tag
if: ${{ !inputs.dry_run }}
run: |
git push origin HEAD
git push origin "${{ steps.resolve.outputs.tag }}"
# ── Step 2: Build installers for each platform ───────────────────
build:
needs: prepare
if: ${{ !inputs.dry_run }}
uses: ./.github/workflows/_build.yml
with:
tag: ${{ needs.prepare.outputs.tag }}
channel: stable
sentry_environment: production
secrets:
MAC_CSC_LINK: ${{ secrets.MAC_CSC_LINK }}
MAC_CSC_KEY_PASSWORD: ${{ secrets.MAC_CSC_KEY_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
# ── Step 3: Create GitHub Release with auto-generated notes ──────
release:
needs: [prepare, build]
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
steps:
- name: Download all build artifacts
uses: actions/download-artifact@v8
with:
path: release-assets
pattern: dist-*
merge-multiple: true
- name: List release assets
run: ls -lh release-assets
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare.outputs.tag }}
name: Lightcode ${{ needs.prepare.outputs.tag }}
generate_release_notes: true
fail_on_unmatched_files: true
files: release-assets/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ── Step 4: Bump master to next plain patch version ──────────────
post-release:
needs: [prepare, release]
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v6
with:
ref: master
fetch-depth: 1
ssh-key: ${{ secrets.RELEASE_DEPLOY_KEY }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Bump to next plain patch version
run: |
node -e "
const fs = require('fs');
const p = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const v = p.version.split('-')[0].split('.').map(Number);
p.version = v[0] + '.' + v[1] + '.' + (v[2] + 1);
fs.writeFileSync('package.json', JSON.stringify(p, null, 2) + '\n');
"
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add package.json
if git diff --cached --quiet; then
echo "No bump needed."
else
git commit -m "chore: bump to next patch version"
git push
fi