forked from rkvishwa/Sonar-Code-Editor
-
Notifications
You must be signed in to change notification settings - Fork 0
244 lines (207 loc) · 6.9 KB
/
Copy pathrelease-draft.yml
File metadata and controls
244 lines (207 loc) · 6.9 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
name: Build and Draft Release
on:
push:
branches:
- releases
permissions:
contents: write
jobs:
build-mac:
runs-on: macos-latest
outputs:
app_version: ${{ steps.get_version.outputs.VERSION }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Get Version from package.json
id: get_version
shell: bash
run: |
# This reads the exact "version" string from package.json
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Cache Electron Binaries
uses: actions/cache@v4
with:
path: |
~/.cache/electron
~/.cache/electron-builder
~/AppData/Local/electron/Cache
~/AppData/Local/electron-builder/Cache
key: ${{ runner.os }}-electron-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-electron-
- name: Install Dependencies
shell: bash
run: |
for attempt in 1 2 3; do
if npm ci; then
exit 0
fi
if [ "$attempt" -eq 3 ]; then
echo "npm ci failed after $attempt attempts"
exit 1
fi
echo "npm ci failed on attempt $attempt. Retrying in 20 seconds..."
sleep 20
done
# We skip the "Set App Version dynamic" step because your package.json is already correct
- name: Create .env file
shell: bash
env:
SECRETS_JSON: ${{ toJson(secrets) }}
run: |
node <<'NODE'
const fs = require('fs');
const secrets = JSON.parse(process.env.SECRETS_JSON || '{}');
const envExample = fs.readFileSync('.env.example', 'utf8');
const missing = [];
const output = [];
envExample.split(/\r?\n/).forEach((line) => {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) {
return;
}
const key = trimmed.split('=')[0].trim();
if (!secrets[key]) {
missing.push(key);
return;
}
output.push(`${key}=${secrets[key]}`);
});
if (missing.length > 0) {
console.error(`Missing required secrets in GitHub Actions: ${missing.join(', ')}`);
process.exit(1);
}
fs.writeFileSync('.env', `${output.join('\n')}\n`);
console.log(`.env file created successfully with ${output.length} entries`);
NODE
- name: Build macOS app (DMG)
run: npm run package:mac
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_IDENTITY_AUTO_DISCOVERY: false
- name: Upload macOS Artifact
uses: actions/upload-artifact@v4
with:
name: mac-build
path: release/*.dmg
build-win:
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Cache Electron Binaries
uses: actions/cache@v4
with:
path: |
~/.cache/electron
~/.cache/electron-builder
~/AppData/Local/electron/Cache
~/AppData/Local/electron-builder/Cache
key: ${{ runner.os }}-electron-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-electron-
- name: Install Dependencies
shell: bash
run: |
for attempt in 1 2 3; do
if npm ci; then
exit 0
fi
if [ "$attempt" -eq 3 ]; then
echo "npm ci failed after $attempt attempts"
exit 1
fi
echo "npm ci failed on attempt $attempt. Retrying in 20 seconds..."
sleep 20
done
- name: Create .env file
shell: bash
env:
SECRETS_JSON: ${{ toJson(secrets) }}
run: |
node <<'NODE'
const fs = require('fs');
const secrets = JSON.parse(process.env.SECRETS_JSON || '{}');
const envExample = fs.readFileSync('.env.example', 'utf8');
const missing = [];
const output = [];
envExample.split(/\r?\n/).forEach((line) => {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) {
return;
}
const key = trimmed.split('=')[0].trim();
if (!secrets[key]) {
missing.push(key);
return;
}
output.push(`${key}=${secrets[key]}`);
});
if (missing.length > 0) {
console.error(`Missing required secrets in GitHub Actions: ${missing.join(', ')}`);
process.exit(1);
}
fs.writeFileSync('.env', `${output.join('\n')}\n`);
console.log(`.env file created successfully with ${output.length} entries`);
NODE
- name: Build Windows app + Microsoft Store package
run: npm run package:win:all
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_SKIP_SIGNING: true
CSC_IDENTITY_AUTO_DISCOVERY: false
- name: Upload Windows Installer Artifact
uses: actions/upload-artifact@v4
with:
name: windows-installer-exe
path: release/*.exe
if-no-files-found: warn
- name: Upload Windows Store Artifact
uses: actions/upload-artifact@v4
with:
name: windows-store-appx
path: release/*.appx
if-no-files-found: warn
create-release:
needs: [build-mac, build-win]
runs-on: ubuntu-latest
steps:
- name: Download macOS Artifacts
uses: actions/download-artifact@v4
with:
name: mac-build
path: artifacts
- name: Download Windows Installer Artifact
uses: actions/download-artifact@v4
with:
name: windows-installer-exe
path: artifacts/windows-exe
- name: Download Windows Store Artifact
uses: actions/download-artifact@v4
with:
name: windows-store-appx
path: artifacts/windows-appx
- name: Create Draft Release
uses: softprops/action-gh-release@v2
with:
draft: true
# This uses the exact version from your package.json
name: Release ${{ needs.build-mac.outputs.app_version }}
tag_name: "v${{ needs.build-mac.outputs.app_version }}"
generate_release_notes: true
files: |
artifacts/*.dmg
artifacts/windows-exe/*.exe
artifacts/windows-appx/*.appx