-
Notifications
You must be signed in to change notification settings - Fork 6
350 lines (328 loc) · 19.5 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
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
name: build
on:
workflow_dispatch:
inputs:
branch:
description: 'The branch to build'
required: true
default: 'main'
tag_version:
description: 'The version of scratch-gui upstream, eg: use 3.0.27 instead of v3.0.27'
required: true
default: '3.0.27'
# https://docs.github.com/zh/actions/using-jobs/assigning-permissions-to-jobs
permissions: write-all
env:
APP_NAME: scratch-app
defaults:
run:
shell: bash
jobs:
build-static-files:
name: Build depoly files for ${{ github.event.inputs.tag_version }}
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
submodules: true
- name: 'Checkout and push specified tag version of scratch'
run: |
git config --global pull.rebase false
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
cd scratch-gui
git status
git remote -v
git fetch --all --tags
git checkout tags/v${{ github.event.inputs.tag_version }}
git status
cd ..
git add scratch-gui
git commit -m "update scratch-gui to v${{ github.event.inputs.tag_version }}"
# update version in README.md using sed
sed -i "s/[0-9]\+\.[0-9]\+\.[0-9]\+/${{ github.event.inputs.tag_version }}/g" README.md
git add README.md
git commit -m "update README.md"
git tag ${{ github.event.inputs.tag_version }}
git push
git push --tag
- name: Use Node.js 18.x
uses: actions/setup-node@v2
with:
node-version: 18.x
cache: 'npm'
- name: 'Building scratch-gui'
run: |
npm install
npm run build
working-directory: scratch-gui
- name: Deploy 🚀
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./scratch-gui/build
- name: Prepare build files achive
run: |
7z a -tzip ${{env.APP_NAME}}-${{ github.event.inputs.tag_version }}.zip -r ./scratch-gui/build/*
- uses: actions/upload-artifact@v2
with:
name: scratch-dist
path: ${{env.APP_NAME}}-${{ github.event.inputs.tag_version }}.zip
- name: 'Publish build files achive to release'
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{ github.event.inputs.tag_version }}
file: ${{env.APP_NAME}}-${{ github.event.inputs.tag_version }}.zip
tags: true
draft: false
overwrite: true
build-native-executable:
name: 'Build native executable'
needs: [build-static-files]
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
include:
- os: 'ubuntu-latest'
label: 'linux'
executable_extension: ''
- os: 'macos-latest'
label: 'macos'
executable_extension: ''
- os: 'windows-latest'
label: 'windows'
executable_extension: '.exe'
runs-on: ${{matrix.os}}
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
submodules: true
- uses: actions/download-artifact@v2
with:
name: scratch-dist
- name: Extract scratch-dist
run: |
rm -rf dist
unzip ${{env.APP_NAME}}-${{ github.event.inputs.tag_version }}.zip -d dist
- name: Display structure of downloaded files
run: ls -l . dist
- name: Use Node.js 18.x
uses: actions/setup-node@v2
with:
node-version: 18.x
cache: 'yarn'
- name: check toolchain version
run: |
node --version
npm --version
yarn --version
rustc --version
cargo --version
- name: 'Setup for linux'
if: matrix.os == 'ubuntu-latest'
run: |-
sudo ls -lR /etc/apt/
echo -------------
# sudo sed 's/mirror+file:\/etc\/apt\/apt-mirrors.txt/[arch-=amd64,i386] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/ports.list
# echo -------------
# sudo sed -i 's/mirror+file:\/etc\/apt\/apt-mirrors.txt/[arch=amd64,i386] http:\/\/archive.ubuntu.com\/ubuntu\//g' /etc/apt/sources.list
cat > /tmp/sources.list << EOF
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy main multiverse universe restricted
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-security main multiverse universe restricted
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-updates main multiverse universe restricted
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu jammy-backports main multiverse universe restricted
deb [arch-=amd64,i386] http://ports.ubuntu.com/ubuntu-ports jammy main multiverse universe restricted
deb [arch-=amd64,i386] http://ports.ubuntu.com/ubuntu-ports jammy-security main multiverse universe restricted
deb [arch-=amd64,i386] http://ports.ubuntu.com/ubuntu-ports jammy-updates main multiverse universe restricted
deb [arch-=amd64,i386] http://ports.ubuntu.com/ubuntu-ports jammy-backports main multiverse universe restricted
EOF
sudo mv /etc/apt/sources.list /etc/apt/sources.list.default
sudo mv /tmp/sources.list /etc/apt/sources.list
echo -------------
echo /etc/apt/sources.list && cat /etc/apt/sources.list
echo -------------
echo /etc/apt/apt-mirrors.txt && cat /etc/apt/apt-mirrors.txt
echo -------------
echo /etc/apt/sources.list.d/ports.list && cat /etc/apt/sources.list.d/ports.list || true
echo -------------
sudo dpkg --add-architecture i386
sudo dpkg --add-architecture arm64
sudo dpkg --add-architecture armhf
sudo apt update
sudo apt install -y \
gcc-multilib \
g++-multilib
echo -------------
echo install dependences ...
sudo apt install -y \
libwebkit2gtk-4.0-dev \
libssl-dev \
libgtk-3-dev \
librsvg2-dev \
libayatana-appindicator3-dev
echo -------------
echo install 32-bit dependences ...
# libayatana-appindicator3-dev:i386 is missing, see https://packages.ubuntu.com/focal/libayatana-appindicator3-dev
sudo apt install -y \
libwebkit2gtk-4.0-dev:i386 \
libssl-dev:i386 \
libgtk-3-dev:i386 \
librsvg2-dev:i386
echo -------------
echo install arm64 dependences ...
sudo apt install -y \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
libc6-dev-arm64-cross \
patchelf:arm64 \
libwebkit2gtk-4.0-dev:arm64 \
libssl-dev:arm64 \
libgtk-3-dev:arm64 \
librsvg2-dev:arm64 \
libayatana-appindicator3-dev:arm64
echo -------------
echo install armhf dependences ...
sudo apt install -y \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf \
libc6-dev-armhf-cross \
patchelf:armhf \
libwebkit2gtk-4.0-dev:armhf \
libssl-dev:armhf \
libgtk-3-dev:armhf \
librsvg2-dev:armhf \
libayatana-appindicator3-dev:armhf
echo 'ok'
- name: 'Setup for macos'
if: matrix.os == 'macos-latest'
run: |
echo 'ok'
- name: 'Setup for windows'
if: matrix.os == 'windows-latest'
run: |
# choco install visualstudio2019-workload-vctools
# https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#visual-studio-enterprise-2019
echo 'ok'
- name: Build Native binarys on ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
echo "build native binarys..."
rustup target add x86_64-unknown-linux-gnu
rustup target add i686-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu
rustup target add armv7-unknown-linux-gnueabihf
yarn
yarn tauri info
yarn tauri build -t x86_64-unknown-linux-gnu -v -c "{\"package\":{\"version\":\"${{ github.event.inputs.tag_version }}\"}}"
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH
export PKG_CONFIG_SYSROOT_DIR=/
yarn tauri build -t i686-unknown-linux-gnu -v -c "{\"package\":{\"version\":\"${{ github.event.inputs.tag_version }}\"}}"
# export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
# export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
# export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
# export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig
# export PKG_CONFIG_ALLOW_CROSS=1
export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/
yarn tauri build -t aarch64-unknown-linux-gnu -v -c "{\"package\":{\"version\":\"${{ github.event.inputs.tag_version }}\"}}" -b deb || echo something not works!
# export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
# export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
# export CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
# export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
# export PKG_CONFIG_ALLOW_CROSS=1
export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/
yarn tauri build -t armv7-unknown-linux-gnueabihf -v -c "{\"package\":{\"version\":\"${{ github.event.inputs.tag_version }}\"}}" -b deb || echo something not works!
echo "build native binarys finished"
- name: Build Native binarys on macos
if: matrix.os == 'macos-latest'
run: |
echo "build native binarys..."
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
yarn
yarn tauri info
yarn tauri build -t x86_64-apple-darwin -c "{\"package\":{\"version\":\"${{ github.event.inputs.tag_version }}\"}}"
yarn tauri build -t aarch64-apple-darwin -c "{\"package\":{\"version\":\"${{ github.event.inputs.tag_version }}\"}}"
yarn tauri build -t universal-apple-darwin -c "{\"package\":{\"version\":\"${{ github.event.inputs.tag_version }}\"}}" || echo something not works!
echo "build native binarys finished"
- name: Build Native binarys on windows
if: matrix.os == 'windows-latest'
run: |
echo "build native binarys..."
rustup target add x86_64-pc-windows-msvc
rustup target add i686-pc-windows-msvc
rustup target add aarch64-pc-windows-msvc
yarn
yarn tauri info
yarn tauri build -t x86_64-pc-windows-msvc -c "{\"package\":{\"version\":\"${{ github.event.inputs.tag_version }}\"}}"
yarn tauri build -t i686-pc-windows-msvc -c "{\"package\":{\"version\":\"${{ github.event.inputs.tag_version }}\"}}"
yarn tauri build -t aarch64-pc-windows-msvc -c "{\"package\":{\"version\":\"${{ github.event.inputs.tag_version }}\"}}" -b nsis || echo something not works!
echo "build native binarys finished"
- name: Display structure of build files
continue-on-error: true
run: |
ls -lR src-tauri/target/
- name: Prepare release files on ${{matrix.label}}
continue-on-error: true
if: matrix.os == 'ubuntu-latest'
run: |
# for 64-bit binary
mv src-tauri/target/x86_64-unknown-linux-gnu/release/${{env.APP_NAME}}${{matrix.executable_extension}} ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_amd64${{matrix.executable_extension}}
mv src-tauri/target/x86_64-unknown-linux-gnu/release/bundle/appimage/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_amd64.AppImage ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_amd64.AppImage
mv src-tauri/target/x86_64-unknown-linux-gnu/release/bundle/deb/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_amd64.deb ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_amd64.deb
# for 32-bit binary
mv src-tauri/target/i686-unknown-linux-gnu/release/${{env.APP_NAME}}${{matrix.executable_extension}} ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_i386${{matrix.executable_extension}}
mv src-tauri/target/i686-unknown-linux-gnu/release/bundle/appimage/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_i386.AppImage ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_i386.AppImage
mv src-tauri/target/i686-unknown-linux-gnu/release/bundle/deb/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_i386.deb ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_i386.deb
# for arm64 binary
mv src-tauri/target/aarch64-unknown-linux-gnu/release/${{env.APP_NAME}}${{matrix.executable_extension}} ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_arm64${{matrix.executable_extension}} || true
# mv src-tauri/target/aarch64-unknown-linux-gnu/release/bundle/appimage/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_arm64.AppImage ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_arm64.AppImage || true
mv src-tauri/target/aarch64-unknown-linux-gnu/release/bundle/deb/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_arm64.deb ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_arm64.deb || true
# for armhf binary
mv src-tauri/target/armv7-unknown-linux-gnueabihf/release/${{env.APP_NAME}}${{matrix.executable_extension}} ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_armhf${{matrix.executable_extension}} || true
# mv src-tauri/target/armv7-unknown-linux-gnueabihf/release/bundle/appimage/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_armhf.AppImage ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_armhf.AppImage || true
mv src-tauri/target/armv7-unknown-linux-gnueabihf/release/bundle/deb/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_armhf.deb ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_armhf.deb || true
- name: Prepare release files on ${{matrix.label}}
continue-on-error: true
if: matrix.os == 'macos-latest'
run: |
mv src-tauri/target/x86_64-apple-darwin/release/${{env.APP_NAME}}${{matrix.executable_extension}} ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_x64${{matrix.executable_extension}}
mv src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_x64.dmg ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_x64.dmg
7z a -tzip ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_x64.app.zip ./src-tauri/target/x86_64-apple-darwin/release/bundle/macos/${{env.APP_NAME}}.app
mv src-tauri/target/aarch64-apple-darwin/release/${{env.APP_NAME}}${{matrix.executable_extension}} ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_aarch64${{matrix.executable_extension}}
mv src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_aarch64.dmg ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_aarch64.dmg
7z a -tzip ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_aarch64.app.zip ./src-tauri/target/aarch64-apple-darwin/release/bundle/macos/${{env.APP_NAME}}.app
mv src-tauri/target/universal-apple-darwin/release/${{env.APP_NAME}}${{matrix.executable_extension}} ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_universal${{matrix.executable_extension}}
mv src-tauri/target/universal-apple-darwin/release/bundle/dmg/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_universal.dmg ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_universal.dmg
7z a -tzip ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_universal.app.zip ./src-tauri/target/universal-apple-darwin/release/bundle/macos/${{env.APP_NAME}}.app
- name: Prepare release files on ${{matrix.label}}
continue-on-error: true
if: matrix.os == 'windows-latest'
run: |
mv src-tauri/target/x86_64-pc-windows-msvc/release/${{env.APP_NAME}}${{matrix.executable_extension}} ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_x64${{matrix.executable_extension}}
mv src-tauri/target/x86_64-pc-windows-msvc/release/bundle/msi/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_x64_en-US.msi ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_x64.msi
mv src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_x64-setup.exe ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_x64-setup.exe
mv src-tauri/target/i686-pc-windows-msvc/release/${{env.APP_NAME}}${{matrix.executable_extension}} ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_x86${{matrix.executable_extension}}
mv src-tauri/target/i686-pc-windows-msvc/release/bundle/msi/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_x86_en-US.msi ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_x86.msi
mv src-tauri/target/i686-pc-windows-msvc/release/bundle/nsis/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_x86-setup.exe ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_x86-setup.exe
mv src-tauri/target/aarch64-pc-windows-msvc/release/${{env.APP_NAME}}${{matrix.executable_extension}} ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_arm64${{matrix.executable_extension}} || true
# mv src-tauri/target/aarch64-pc-windows-msvc/release/bundle/msi/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_arm64_en-US.msi ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_arm64.msi || true
mv src-tauri/target/aarch64-pc-windows-msvc/release/bundle/nsis/${{env.APP_NAME}}_${{ github.event.inputs.tag_version }}_arm64-setup.exe ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}_arm64-setup.exe || true
- name: Display structure of build files
run: |
ls -l .
- name: 'Publish binary to release'
continue-on-error: true
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{ github.event.inputs.tag_version }}
file: ${{env.APP_NAME}}-${{matrix.label}}-${{ github.event.inputs.tag_version }}*
tags: true
draft: false
overwrite: true