This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
372 lines (322 loc) · 12.1 KB
/
electron_ci.yml
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# The purpose of this workflow is to fully publish new releases.
# It builds, tests, and publishes a new release along with its changelog.
name: electron-ci
on:
push:
branches:
- '**'
jobs:
build-extras:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Build Remeshes
run: |
npm install
npm run build
working-directory: extras/fsolauncher-remeshes
- name: Build Proxy
run: |
npm install
npm run build
working-directory: extras/fsolauncher-proxy
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: fsolauncher-extras
path: |
release/remeshes-*.zip
release/proxy-*
build-launcher:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
include:
- os: windows-latest
build_command: "buildwin"
artifact_name: "fsolauncher-win32"
- os: macos-latest
build_command: "builddarwin"
artifact_name: "fsolauncher-darwin"
- os: ubuntu-latest
build_command: "builddeb"
artifact_name: "fsolauncher-debian"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Replace Sentry DSN and Browser Loader (Windows)
if: matrix.os == 'windows-latest'
working-directory: app
run: |
(Get-Content sentry.config.js) -replace "SENTRY_CI_DSN", "${{ secrets.SENTRY_CI_DSN }}" | Set-Content sentry.config.js
(Get-Content sentry.config.js) -replace "SENTRY_CI_BROWSER_LOADER", "${{ secrets.SENTRY_CI_BROWSER_LOADER }}" | Set-Content sentry.config.js
- name: Replace Sentry DSN and Browser Loader (macOS)
if: matrix.os == 'macos-latest'
working-directory: app
run: |
sed "s#SENTRY_CI_DSN#${{ secrets.SENTRY_CI_DSN }}#g" sentry.config.js > sentry.config.temp.js
mv sentry.config.temp.js sentry.config.js
sed "s#SENTRY_CI_BROWSER_LOADER#${{ secrets.SENTRY_CI_BROWSER_LOADER }}#g" sentry.config.js > sentry.config.temp.js
mv sentry.config.temp.js sentry.config.js
- name: Replace Sentry DSN and Browser Loader (Debian)
if: matrix.os == 'ubuntu-latest'
working-directory: app
run: |
sed "s#SENTRY_CI_DSN#${{ secrets.SENTRY_CI_DSN }}#g" sentry.config.js > sentry.config.temp.js
mv sentry.config.temp.js sentry.config.js
sed "s#SENTRY_CI_BROWSER_LOADER#${{ secrets.SENTRY_CI_BROWSER_LOADER }}#g" sentry.config.js > sentry.config.temp.js
mv sentry.config.temp.js sentry.config.js
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Cache Electron binaries
id: cache-electron-binaries
uses: actions/cache@v2
with:
path: |
~/.electron
~/Library/Caches/electron
~/AppData/Local/electron/Cache/
key: ${{ runner.os }}-electron-binaries-${{ hashFiles('app/package-lock.json') }}
restore-keys: |
${{ runner.os }}-electron-binaries-
- name: Cache Node.js modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: app/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('app/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Playwright Skip Browser Download
run: echo "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1" >> $GITHUB_ENV
- name: python3 fix
if: matrix.os == 'macos-latest'
run: python3 -m pip install setuptools --break-system-packages
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
working-directory: app
- name: Run ESLint
run: npm run lint
working-directory: app
- name: Build
run: npm run ${{ matrix.build_command }}
working-directory: app
- name: Run E2E tests on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test
env:
GITHUB_RATELIMIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: app
- name: Run E2E tests
if: matrix.os != 'ubuntu-latest'
run: npm run test
env:
GITHUB_RATELIMIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: app
- name: List contents of the release directory (Windows)
if: matrix.os == 'windows-latest'
run: |
dir "release"
- name: List contents of the release directory (macOS)
if: matrix.os == 'macos-latest'
run: |
ls -la release
- name: List contents of the release directory (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
ls -la release
- name: Upload artifacts (Windows)
uses: actions/upload-artifact@v2
if: matrix.os == 'windows-latest'
with:
name: ${{ matrix.artifact_name }}
path: |
release/FreeSO Launcher Setup.exe
- name: Upload artifacts (macOS)
uses: actions/upload-artifact@v2
if: matrix.os == 'macos-latest'
with:
name: ${{ matrix.artifact_name }}
path: |
release/FreeSO Launcher.dmg
- name: Upload artifacts
uses: actions/upload-artifact@v2
if: matrix.os == 'ubuntu-latest'
with:
name: ${{ matrix.artifact_name }}
path: |
release/FreeSO Launcher.deb
create-release:
needs: [build-launcher, build-extras]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get version
uses: nyaa8/package-version@v1
with:
path: 'app/package.json'
follow-symlinks: 'false'
- name: Calculate release type counter
id: release_type_counter
run: |
git fetch --prune --unshallow --tags
branch_name="${GITHUB_REF#refs/heads/}"
sanitized_branch_name="${branch_name//[^a-zA-Z0-9]/-}"
if [ "$branch_name" == "main" ]; then
release_type="prod"
elif [ "$branch_name" == "develop" ]; then
release_type="alpha"
else
release_type=$sanitized_branch_name
fi
echo "RELEASE_TYPE=$release_type" >> $GITHUB_ENV
tags_with_counter=$(git tag --list | grep -E "^${{ env.PACKAGE_VERSION }}-${release_type}\.[0-9]+$" || true)
max_counter=0
for tag in $tags_with_counter; do
current_counter=$(echo $tag | sed -E "s/^${{ env.PACKAGE_VERSION }}-${release_type}\.([0-9]+)$/\1/")
if [[ $current_counter -gt $max_counter ]]; then
max_counter=$current_counter
fi
done
counter=$((max_counter + 1))
echo "COUNTER=$counter" >> $GITHUB_ENV
full_version_name="${{ env.PACKAGE_VERSION }}-$release_type.$counter"
echo "FULL_VERSION_NAME=$full_version_name" >> $GITHUB_ENV
- name: Get latest release tag
id: latest_release_tag
run: |
release_type="${{ env.RELEASE_TYPE }}"
latest_release_tag=$(git tag --sort=committerdate | grep -E "${release_type}\.[0-9]+$" | tail -1 || true)
if [ -z "$latest_release_tag" ]; then
echo "No previous tag found for release type $release_type"
else
echo "LATEST_RELEASE_TAG=$latest_release_tag" >> $GITHUB_ENV
fi
- name: Generate release notes
id: release_notes
run: |
if [ "${{ env.RELEASE_TYPE }}" == "prod" ]; then
release_notes="This is a stable release suitable for reliable end-user experience and optimized for production use."
else
release_notes="This is a pre-release version meant for development and testing."
fi
commit_count=$(git rev-list --count ${{ env.LATEST_RELEASE_TAG }}..HEAD)
if [ "$commit_count" != "0" ]; then
if [ "$commit_count" == "1" ]; then
changes_word="change"
verb="has"
else
changes_word="changes"
verb="have"
fi
release_notes=$(printf "%s\n\nThere %s been %s %s since the last release. See the [list of changes](https://github.com/${{ github.repository }}/compare/${{ env.LATEST_RELEASE_TAG }}...${{ env.FULL_VERSION_NAME }})." "$release_notes" "$verb" "$commit_count" "$changes_word")
fi
echo "$release_notes" > release_notes.txt
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ env.FULL_VERSION_NAME }}
name: Release ${{ env.FULL_VERSION_NAME }}
body_path: release_notes.txt
draft: false
prerelease: ${{ github.ref != 'refs/heads/main' }}
- name: Download artifacts (Windows)
uses: actions/download-artifact@v2
with:
name: fsolauncher-win32
path: release
- name: Download artifacts (macOS)
uses: actions/download-artifact@v2
with:
name: fsolauncher-darwin
path: release
- name: Download artifacts (Debian)
uses: actions/download-artifact@v2
with:
name: fsolauncher-debian
path: release
- name: Download launcher extras
uses: actions/download-artifact@v2
with:
name: fsolauncher-extras
path: release
- name: Remove junk from release folder
run: |
rm -f release/*.iss release/README.md
- name: Rename files to final artifact names
run: |
version=${{ env.FULL_VERSION_NAME }}
mv release/FreeSO\ Launcher\ Setup.exe release/fsolauncher-$version.exe
mv release/FreeSO\ Launcher.dmg release/fsolauncher-$version.dmg
mv release/FreeSO\ Launcher.deb release/fsolauncher-$version.deb
- name: Find Remeshes File
id: find_remeshes_file
run: |
remeshes_file=$(ls release/remeshes-*.zip)
echo "REMESHES_FILE=$remeshes_file" >> $GITHUB_ENV
echo "Found remeshes file: $remeshes_file"
- name: Find Proxy File
id: find_proxy_file
run: |
proxy_file=$(ls release/proxy-*)
echo "PROXY_FILE=$proxy_file" >> $GITHUB_ENV
echo "Found proxy file: $proxy_file"
- name: Conglomerate SHA256 Hashes
run: |
echo "Calculating SHA256 for all files in release directory..."
cd release
> SHASUMS256.txt
for file in *; do
# Skip SHASUMS256.txt and any other specific files you wish to exclude
if [[ "$file" == "SHASUMS256.txt" ]]; then
continue
fi
if [ -f "$file" ]; then # Ensure it's a file
shasum -a 256 "$file" | awk '{print $1, $2}' >> SHASUMS256.txt
fi
done
# Output the contents of SHASUMS256.txt to the console for debugging
echo "SHA256 sums of all files:"
cat SHASUMS256.txt
cd ..
- name: Upload release assets
uses: actions/github-script@v5
with:
script: |
const fs = require( 'fs' );
const path = require( 'path' );
const directoryPath = 'release';
const files = fs.readdirSync( directoryPath );
const release = await github.rest.repos.getReleaseByTag( {
owner: context.repo.owner,
repo: context.repo.repo,
tag: process.env.FULL_VERSION_NAME,
} );
for ( const file of files ) {
const filePath = path.join( directoryPath, file );
const content = fs.readFileSync( filePath );
await github.rest.repos.uploadReleaseAsset( {
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: file,
data: content,
headers: {
'content-type': 'application/octet-stream',
'content-length': content.length
}
} );
}
github-token: ${{ secrets.GITHUB_TOKEN }}