-
Notifications
You must be signed in to change notification settings - Fork 14
336 lines (296 loc) · 9.92 KB
/
build-and-release.yml
File metadata and controls
336 lines (296 loc) · 9.92 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
name: Build and Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
draft_release:
description: 'Create draft release'
required: false
type: boolean
default: false
version:
description: 'Version tag (optional, uses run number if empty)'
required: false
type: string
jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x64, arm64]
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: |
pnpm config set fund false
pnpm install --frozen-lockfile
- name: Build Linux ${{ matrix.arch }}
run: |
if [ "${{ matrix.arch }}" = "x64" ]; then
pnpm run build:linux --x64
else
pnpm run build:linux --${{ matrix.arch }}
fi
- name: Upload Linux artifacts
uses: actions/upload-artifact@v4
with:
name: p-stream-linux-${{ matrix.arch }}
path: dist/*.AppImage
retention-days: 30
build-windows:
runs-on: windows-latest
strategy:
matrix:
arch: [x64, arm64]
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: |
pnpm config set fund false
pnpm install --frozen-lockfile
- name: Build Windows ${{ matrix.arch }}
shell: bash
run: |
if [ "${{ matrix.arch }}" = "x64" ]; then
pnpm run build:win --x64
else
pnpm run build:win --${{ matrix.arch }}
fi
- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: p-stream-windows-${{ matrix.arch }}
path: |
dist/*.exe
dist/*.zip
retention-days: 30
build-macos:
runs-on: macos-latest
strategy:
matrix:
arch: [x64, arm64]
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: |
pnpm config set fund false
pnpm install --frozen-lockfile
- name: Build macOS ${{ matrix.arch }}
run: |
if [ "${{ matrix.arch }}" = "x64" ]; then
pnpm run build:mac --x64
else
pnpm run build:mac --${{ matrix.arch }}
fi
- name: Upload macOS artifacts
uses: actions/upload-artifact@v4
with:
name: p-stream-macos-${{ matrix.arch }}
path: |
dist/*.dmg
dist/*.zip
retention-days: 30
release:
needs: [build-linux, build-windows, build-macos]
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event.inputs.draft_release == 'true'
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create draft release (if triggered manually)
if: github.event.inputs.draft_release == 'true'
run: |
VERSION_TAG="${{ github.event.inputs.version }}"
if [ -z "$VERSION_TAG" ]; then
VERSION_TAG="draft-${{ github.run_number }}"
fi
gh release create "$VERSION_TAG" \
--title "Draft Release ${{ github.run_number }}" \
--notes "Automated draft release" \
--draft \
--prerelease
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: |
pnpm config set fund false
pnpm install --frozen-lockfile
- name: Upload Release Assets and Generate Update Metadata
run: |
# Determine release tag
if [ "${{ github.event.inputs.draft_release }}" = "true" ]; then
VERSION_TAG="${{ github.event.inputs.version }}"
if [ -z "$VERSION_TAG" ]; then
RELEASE_TAG="draft-${{ github.run_number }}"
else
RELEASE_TAG="$VERSION_TAG"
fi
else
RELEASE_TAG="${{ github.event.release.tag_name }}"
fi
echo "Uploading to release: $RELEASE_TAG"
# Extract version from package.json
VERSION=$(node -p "require('./package.json').version")
echo "App version: $VERSION"
# Find and upload all built artifacts, and collect info for update files
mkdir -p update-metadata
# First pass: Upload all files and collect metadata (prefer x64)
LINUX_FILE=""
WINDOWS_FILE=""
MACOS_FILE=""
LINUX_SHA512=""
WINDOWS_SHA512=""
MACOS_SHA512=""
LINUX_SIZE=""
WINDOWS_SIZE=""
MACOS_SIZE=""
for file in ./artifacts/*/*; do
if [ -f "$file" ]; then
filename=$(basename "$file")
echo "Uploading $filename..."
gh release upload "$RELEASE_TAG" "$file" --clobber
# Get file size and SHA512 for update metadata
SIZE=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null || echo "0")
# Generate SHA512 hash (required for electron-updater)
if command -v shasum > /dev/null; then
SHA512=$(shasum -a 512 "$file" | cut -d' ' -f1)
elif command -v sha512sum > /dev/null; then
SHA512=$(sha512sum "$file" | cut -d' ' -f1)
else
echo "Error: Cannot generate SHA512 hash. Install shasum or sha512sum."
exit 1
fi
# Determine platform and collect file info (prefer x64)
if [[ "$filename" == *.AppImage ]]; then
if [[ "$filename" == *x64* ]] || [ -z "$LINUX_FILE" ]; then
LINUX_FILE="$filename"
LINUX_SHA512="$SHA512"
LINUX_SIZE="$SIZE"
fi
elif [[ "$filename" == *.exe ]]; then
if [[ "$filename" == *x64* ]] || [ -z "$WINDOWS_FILE" ]; then
WINDOWS_FILE="$filename"
WINDOWS_SHA512="$SHA512"
WINDOWS_SIZE="$SIZE"
fi
elif [[ "$filename" == *.dmg ]]; then
if [ -z "$MACOS_FILE" ]; then
MACOS_FILE="$filename"
MACOS_SHA512="$SHA512"
MACOS_SIZE="$SIZE"
fi
elif [[ "$filename" == *.zip ]]; then
# Only use .zip if .dmg wasn't found
if [ -z "$MACOS_FILE" ]; then
MACOS_FILE="$filename"
MACOS_SHA512="$SHA512"
MACOS_SIZE="$SIZE"
fi
fi
fi
done
# Generate update metadata files
RELEASE_DATE=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
if [ -n "$LINUX_FILE" ]; then
{
echo "version: $VERSION"
echo "files:"
echo " - url: $LINUX_FILE"
echo " sha512: $LINUX_SHA512"
echo " size: $LINUX_SIZE"
echo "path: $LINUX_FILE"
echo "sha512: $LINUX_SHA512"
echo "releaseDate: $RELEASE_DATE"
} > "update-metadata/latest-linux.yml"
fi
if [ -n "$WINDOWS_FILE" ]; then
{
echo "version: $VERSION"
echo "files:"
echo " - url: $WINDOWS_FILE"
echo " sha512: $WINDOWS_SHA512"
echo " size: $WINDOWS_SIZE"
echo "path: $WINDOWS_FILE"
echo "sha512: $WINDOWS_SHA512"
echo "releaseDate: $RELEASE_DATE"
} > "update-metadata/latest.yml"
fi
if [ -n "$MACOS_FILE" ]; then
{
echo "version: $VERSION"
echo "files:"
echo " - url: $MACOS_FILE"
echo " sha512: $MACOS_SHA512"
echo " size: $MACOS_SIZE"
echo "path: $MACOS_FILE"
echo "sha512: $MACOS_SHA512"
echo "releaseDate: $RELEASE_DATE"
} > "update-metadata/latest-mac.yml"
fi
# Upload update metadata files
if ls update-metadata/*.yml 1> /dev/null 2>&1; then
echo "Uploading update metadata files..."
for yml in update-metadata/*.yml; do
filename=$(basename "$yml")
echo "Uploading $filename..."
gh release upload "$RELEASE_TAG" "$yml" --clobber
done
echo "Update metadata files uploaded successfully"
else
echo "Warning: No update metadata files were generated"
echo "This may cause update checks to fail"
fi
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}