-
Notifications
You must be signed in to change notification settings - Fork 4
291 lines (251 loc) · 10.3 KB
/
electron.yaml
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
name: Build portable Electron versions
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: write
pages: write
id-token: write
pull-requests: write
issues: write
actions: read
checks: write
jobs:
vite-build:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Set up Node.js
uses: actions/setup-node@main
with:
node-version: "21"
- name: Install Dependencies
run: npm ci --force
- name: Build Vite App
run: npm run vitebuildcli
- name: Upload Vite Build Artifact
uses: actions/upload-artifact@main
with:
name: vite-dist
path: ./dist
build:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: macos-latest
arch: [x64, arm64]
- os: windows-latest
arch: [x64, arm64]
runs-on: ${{ matrix.os }}
needs: vite-build
outputs:
mac_x64_artifact_id: ${{ steps.upload-mac-x64.outputs.artifact-id }}
mac_arm64_artifact_id: ${{ steps.upload-mac-arm64.outputs.artifact-id }}
win_x64_artifact_id: ${{ steps.upload-win-x64.outputs.artifact-id }}
win_arm64_artifact_id: ${{ steps.upload-win-arm64.outputs.artifact-id }}
linux_x64_artifact_id: ${{ steps.upload-linux-x64.outputs.artifact-id }}
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Download Vite Build Artifact
uses: actions/download-artifact@main
with:
name: vite-dist
path: ./dist
- name: Get version from package.json
id: get_version
run: |
echo "PACKAGE_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
- name: Set up Node.js
uses: actions/setup-node@main
with:
node-version: "21"
- name: Cache Node.js dependencies
uses: actions/cache@main
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Set up Python (macOS only)
if: matrix.os == 'macos-latest'
uses: actions/setup-python@main
with:
python-version: "3.12"
- name: Cache Python dependencies (macOS only)
if: matrix.os == 'macos-latest'
uses: actions/cache@main
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache Electron build (all platforms)
uses: actions/cache@main
with:
path: |
${{ github.workspace }}/.electron
${{ github.workspace }}/.cache/electron
${{ github.workspace }}/.cache/electron-builder
key: ${{ runner.os }}-electron-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-electron-cache-
- name: Install Python virtual environment (macOS only)
if: matrix.os == 'macos-latest'
run: |
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip setuptools
- name: Ensure package-lock.json is up to date
run: npm install --force
env:
CI: true
- name: Install dependencies (Ubuntu and macOS)
if: matrix.os != 'windows-latest'
run: |
if [ "${{ matrix.os }}" = "macos-latest" ]; then
source venv/bin/activate
npm install appdmg --save-dev --force
fi
npm ci --force
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
run: npm ci --force
- name: Build Electron app (macOS)
if: matrix.os == 'macos-latest'
run: |
source venv/bin/activate
for arch in ${{ join(matrix.arch, ' ') }}; do
npm run makecli -- --arch=$arch
mkdir -p out/make-mac-$arch
mv out/make/* out/make-mac-$arch/
done
- name: Build Electron app (Windows)
if: matrix.os == 'windows-latest'
run: |
$architectures = @("x64", "arm64")
foreach ($arch in $architectures) {
npm run makecli -- --arch=$arch
New-Item -ItemType Directory -Force -Path "out/make-win-$arch"
Move-Item -Path "out/make/*" -Destination "out/make-win-$arch/"
}
env:
CSC_IDENTITY_AUTO_DISCOVERY: false
- name: Build Electron app (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
npm run makecli
mkdir -p out/make-linux
mv out/make/* out/make-linux/
env:
CSC_IDENTITY_AUTO_DISCOVERY: false
- name: Upload Artifacts (macOS x64)
if: matrix.os == 'macos-latest' && contains(matrix.arch, 'x64')
id: upload-mac-x64
uses: actions/upload-artifact@main
with:
name: iSpeakerReact-macos-x64
path: out/make-mac-x64
- name: Upload Artifacts (macOS arm64)
if: matrix.os == 'macos-latest' && contains(matrix.arch, 'arm64')
id: upload-mac-arm64
uses: actions/upload-artifact@main
with:
name: iSpeakerReact-macos-arm64
path: out/make-mac-arm64
- name: Upload Artifacts (Windows x64)
if: matrix.os == 'windows-latest' && contains(matrix.arch, 'x64')
id: upload-win-x64
uses: actions/upload-artifact@main
with:
name: iSpeakerReact-windows-x64
path: out/make-win-x64
- name: Upload Artifacts (Windows arm64)
if: matrix.os == 'windows-latest' && contains(matrix.arch, 'arm64')
id: upload-win-arm64
uses: actions/upload-artifact@main
with:
name: iSpeakerReact-windows-arm64
path: out/make-win-arm64
- name: Upload Artifacts (Linux x64)
if: matrix.os == 'ubuntu-latest'
id: upload-linux-x64
uses: actions/upload-artifact@main
with:
name: iSpeakerReact-linux-x64
path: out/make-linux
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@main
with:
fetch-depth: 0
- name: Download all build artifacts
uses: actions/download-artifact@main
with:
path: ./release
- name: Get version from package.json
id: get_version
run: |
echo "PACKAGE_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
- name: Get latest tag
id: get_tag
run: |
latest_tag=$(git tag | sort -V | tail -n 1)
if [ -z "$latest_tag" ]; then
new_tag="v${{ env.PACKAGE_VERSION }}"
else
random_str=$(openssl rand -hex 4)
version_prefix=${{ env.PACKAGE_VERSION }}
new_tag="${version_prefix}-${random_str}"
fi
echo "LATEST_TAG=$new_tag" >> $GITHUB_ENV
- name: Create tag
run: |
git tag ${{ env.LATEST_TAG }}
git push origin ${{ env.LATEST_TAG }}
- name: Create GitHub release
id: create_release
uses: softprops/action-gh-release@c43d7637b9b9ce3e953168c325d27253a5d48d8e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.LATEST_TAG }}
name: v${{ env.PACKAGE_VERSION }}
body: |
Release version ${{ env.PACKAGE_VERSION }} of the project.
- name: Display the release directory structure
run: ls -R ./release
- name: Upload Release Assets
run: |
for artifact in ./release/iSpeakerReact-*; do
if [ -d "$artifact" ]; then
find "$artifact" -type f -print0 | while IFS= read -r -d '' file; do
if [[ "$file" == *"RELEASES"* || "$file" == *.nupkg ]]; then
echo "Skipping $file"
continue
fi
echo "Attempting to upload: $file"
if gh release upload "${{ env.LATEST_TAG }}" "$file" --clobber; then
echo "Successfully uploaded: $file"
else
echo "Failed to upload: $file"
fi
done
else
echo "No artifact found in $artifact"
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}