-
Notifications
You must be signed in to change notification settings - Fork 56
260 lines (246 loc) · 15 KB
/
build.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
name: Build
on:
push:
branches:
- "*"
tags-ignore:
- "*"
pull_request:
release:
types: [published]
jobs:
compile:
name: Check & Compile
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"
cache: "npm"
- name: Install Node.js dependencies
run: npm ci
env:
ASCOPE_NO_FFMPEG: true
- name: Check formatting
run: npm run check-format
- name: Compile bundles
run: npm run compile
- name: Upload bundles
uses: actions/upload-artifact@v3
with:
name: bundles
path: bundles/*.js
build-win:
name: Build for Windows (${{ matrix.arch }})
needs: compile
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
arch: ["x64", "arm64"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"
cache: "npm"
- name: Install Node.js dependencies
run: npm ci
- name: Download bundles
uses: actions/download-artifact@v3
with:
name: bundles
path: bundles
- name: Build app
run: npx electron-builder build --${{ matrix.arch }} --publish never
env:
NODE_OPTIONS: --max-old-space-size=4096
- name: Prepare artifact
run: |
Move-Item -Path "dist\AdvantageScope*.exe" -Destination "advantagescope-win-${{ matrix.arch }}-dev.exe"
- name: Upload development artifact
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: advantagescope-win-${{ matrix.arch }}-dev.exe
path: advantagescope-win-${{ matrix.arch }}-dev.exe
- name: "Release: Get release info"
if: github.event_name == 'release'
id: get_release_info
uses: kaliber5/action-get-release@v1
with:
token: ${{ github.token }}
- name: "Release: Upload artifact"
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: advantagescope-win-${{ matrix.arch }}-dev.exe
asset_name: advantagescope-win-${{ matrix.arch }}-${{ steps.get_release_info.outputs.tag_name }}.exe
asset_content_type: "application/octet-stream"
build-mac:
name: Build for macOS (${{ matrix.arch }})
needs: compile
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
arch: ["x64", "arm64"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"
cache: "npm"
- name: Install Node.js dependencies
run: npm ci
- name: Load macOS certificate
if: github.event_name != 'pull_request'
run: |
echo "CSC_LINK=${{ secrets.MACOS_CERTIFICATE }}" >> $GITHUB_ENV
echo "CSC_KEY_PASSWORD=${{ secrets.MACOS_CERTIFICATE_PWD }}" >> $GITHUB_ENV
- name: Load macOS notarization credentials
if: github.event_name == 'release'
run: |
echo "APPLE_ID=${{ secrets.MACOS_APPLE_ID }}" >> $GITHUB_ENV
echo "APPLE_ID_PWD=${{ secrets.MACOS_APPLE_ID_PWD }}" >> $GITHUB_ENV
echo "APPLE_ID_TEAM=${{ secrets.MACOS_APPLE_ID_TEAM }}" >> $GITHUB_ENV
- name: Download bundles
uses: actions/download-artifact@v3
with:
name: bundles
path: bundles
- name: Build app
run: npx electron-builder build --${{ matrix.arch }} --publish never
env:
NODE_OPTIONS: --max-old-space-size=4096
- name: Prepare artifact
run: |
mv dist/AdvantageScope-*.dmg advantagescope-mac-${{ matrix.arch }}-dev.dmg
- name: Upload development artifact
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: advantagescope-mac-${{ matrix.arch }}-dev.dmg
path: advantagescope-mac-${{ matrix.arch }}-dev.dmg
- name: "Release: Get release info"
if: github.event_name == 'release'
id: get_release_info
uses: kaliber5/action-get-release@v1
with:
token: ${{ github.token }}
- name: "Release: Upload artifact"
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: advantagescope-mac-${{ matrix.arch }}-dev.dmg
asset_name: advantagescope-mac-${{ matrix.arch }}-${{ steps.get_release_info.outputs.tag_name }}.dmg
asset_content_type: "application/octet-stream"
build-linux:
name: Build for Linux/${{ matrix.format }} (${{ matrix.arch.electronArch }})
needs: compile
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
format: ${{ fromJson(github.event_name == 'release' && '["deb", "rpm", "pacman", "AppImage", "snap", "flatpak"]' || '["AppImage"]') }}
arch:
- { electronArch: "x64", flatpakArch: "x86_64" }
- { electronArch: "arm64", flatpakArch: "aarch64" }
- { electronArch: "armv7l", flatpakArch: "" }
exclude:
- arch: { electronArch: "arm64", flatpakArch: "aarch64" }
format: "snap"
- arch: { electronArch: "armv7l", flatpakArch: "" }
format: "flatpak"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"
cache: "npm"
- name: Install Node.js dependencies
run: npm ci
- name: Install Linux packages
run: |
sudo apt-get update; sudo apt-get install --no-install-recommends -y libarchive-tools snapcraft
- name: Install flatpak packages
if: matrix.format == 'flatpak'
run: |
sudo apt-get install -y flatpak flatpak-builder
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
sudo flatpak install flathub org.freedesktop.Platform/${{ matrix.arch.flatpakArch }}/22.08 --assumeyes
sudo flatpak install flathub org.freedesktop.Sdk/${{ matrix.arch.flatpakArch }}/22.08 --assumeyes
sudo flatpak install flathub org.electronjs.Electron2.BaseApp/${{ matrix.arch.flatpakArch }}/22.08 --assumeyes
- name: Download bundles
uses: actions/download-artifact@v3
with:
name: bundles
path: bundles
- name: Build app
run: npx electron-builder build --${{ matrix.arch.electronArch }} -l ${{ matrix.format }} --publish never
env:
NODE_OPTIONS: --max-old-space-size=4096
- name: Prepare artifact
run: |
mv dist/*.${{ matrix.format }} advantagescope-linux-${{ matrix.arch.electronArch }}-dev.${{ matrix.format }}
- name: Upload development artifact
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: advantagescope-linux-${{ matrix.arch.electronArch }}-dev.${{ matrix.format }}
path: advantagescope-linux-${{ matrix.arch.electronArch }}-dev.${{ matrix.format }}
- name: "Release: Get release info"
if: github.event_name == 'release'
id: get_release_info
uses: kaliber5/action-get-release@v1
with:
token: ${{ github.token }}
- name: "Release: Upload artifact"
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: advantagescope-linux-${{ matrix.arch.electronArch }}-dev.${{ matrix.format }}
asset_name: advantagescope-linux-${{ matrix.arch.electronArch }}-${{ steps.get_release_info.outputs.tag_name }}.${{ matrix.format }}
asset_content_type: "application/octet-stream"
finalize-release:
name: Finalize Release
needs: [build-win, build-mac, build-linux]
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Get release info
id: get_release_info
uses: kaliber5/action-get-release@v1
with:
token: ${{ github.token }}
- name: Edit release
uses: irongut/EditRelease@v1.2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
id: ${{ github.event.release.id }}
prerelease: false
replacebody: false
body: '<table><tr><th colspan="4">Common Downloads</th></tr><tr><td colspan="4">🪟 <a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-win-x64-${{ steps.get_release_info.outputs.tag_name }}.exe">Windows x64</a></td></tr><tr><td colspan="4">🍎 <a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-mac-arm64-${{ steps.get_release_info.outputs.tag_name }}.dmg">macOS Apple Silicon</a></td></tr><tr><td colspan="4">🍎 <a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-mac-x64-${{ steps.get_release_info.outputs.tag_name }}.dmg">macOS Intel</a></td></tr><tr><td colspan="4">🐧 <a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-x64-${{ steps.get_release_info.outputs.tag_name }}.deb">Linux x86 Deb</a></td></tr><tr><th colspan="4">All Downloads</th></tr><tr><td>Windows</td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-win-x64-${{ steps.get_release_info.outputs.tag_name }}.exe">x64</a></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-win-arm64-${{ steps.get_release_info.outputs.tag_name }}.exe">arm64</a></td><td></td></tr><tr><td>macOS</td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-mac-x64-${{ steps.get_release_info.outputs.tag_name }}.dmg">x64</a></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-mac-arm64-${{ steps.get_release_info.outputs.tag_name }}.dmg">arm64</a></td><td></td></tr><tr><td>Linux/deb</td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-x64-${{ steps.get_release_info.outputs.tag_name }}.deb">x64</a></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-arm64-${{ steps.get_release_info.outputs.tag_name }}.deb">arm64</a></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-armv7l-${{ steps.get_release_info.outputs.tag_name }}.deb">arm32</a></td></tr><tr><td>Linux/rpm</td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-x64-${{ steps.get_release_info.outputs.tag_name }}.rpm">x64</a></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-arm64-${{ steps.get_release_info.outputs.tag_name }}.rpm">arm64</a></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-armv7l-${{ steps.get_release_info.outputs.tag_name }}.rpm">arm32</a></td></tr><tr><td>Linux/pacman</td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-x64-${{ steps.get_release_info.outputs.tag_name }}.pacman">x64</a></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-arm64-${{ steps.get_release_info.outputs.tag_name }}.pacman">arm64</a></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-armv7l-${{ steps.get_release_info.outputs.tag_name }}.pacman">arm32</a></td></tr><tr><td>Linux/AppImage</td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-x64-${{ steps.get_release_info.outputs.tag_name }}.AppImage">x64</a></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-arm64-${{ steps.get_release_info.outputs.tag_name }}.AppImage">arm64</a></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-armv7l-${{ steps.get_release_info.outputs.tag_name }}.AppImage">arm32</a></td></tr><tr><td>Linux/snap</td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-x64-${{ steps.get_release_info.outputs.tag_name }}.snap">x64</a></td><td></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-armv7l-${{ steps.get_release_info.outputs.tag_name }}.snap">arm32</a></td></tr><tr><td>Linux/flatpak</td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-x64-${{ steps.get_release_info.outputs.tag_name }}.flatpak">x64</a></td><td><a href="https://github.com/Mechanical-Advantage/AdvantageScope/releases/download/${{ steps.get_release_info.outputs.tag_name }}/advantagescope-linux-arm64-${{ steps.get_release_info.outputs.tag_name }}.flatpak">arm64</a></td><td></td></tr></table>'
- name: Mark as latest
run: |
gh api --method PATCH -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/Mechanical-Advantage/AdvantageScope/releases/${{ github.event.release.id }} -f make_latest=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}