-
Notifications
You must be signed in to change notification settings - Fork 308
366 lines (320 loc) · 14.4 KB
/
Release.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
name: Release
on:
workflow_dispatch:
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
RUST_TOOLCHAIN: nightly-2024-04-15
NDK_VERSION: 25.2.9519653
jobs:
ci-pass:
name: CI is green
runs-on: ubuntu-latest
needs:
- check_release
- build_release_assets
- community_notify
steps:
- run: exit 0
check_release:
name: Check release
runs-on: ubuntu-latest
steps:
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner .os }}-cargo-
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Checkout
uses: actions/checkout@v3
with:
repository: ${{ github.event.inputs.repo }}
ref: 'master'
- name: Check release
run: |
cd ci
cargo run --bin check-release
build_release_assets:
name: Build release assets
needs:
- check_release
strategy:
fail-fast: false
matrix:
config:
- target: linux
host: ubuntu-latest
flutter_version: '3.10.5'
flutter_channel: 'stable'
- target: windows
host: windows-latest
flutter_version: '3.10.5'
flutter_channel: 'stable'
- target: macos
host: macos-latest
flutter_version: '3.10.5'
flutter_channel: 'stable'
- target: ios
host: macos-latest
flutter_version: '3.10.5'
flutter_channel: 'stable'
- target: android-arm32
host: ubuntu-latest
flutter_version: '3.10.5'
flutter_channel: 'stable'
- target: android-arm64
host: ubuntu-latest
flutter_version: '3.10.5'
flutter_channel: 'stable'
- target: android-x86_64
host: ubuntu-latest
flutter_version: '3.10.5'
flutter_channel: 'stable'
# - target: android-arm32
# host: ubuntu-latest
# flutter_version: '2.10.5'
# flutter_channel: 'stable'
# - target: android-arm64
# host: ubuntu-latest
# flutter_version: '2.10.5'
# flutter_channel: 'stable'
# - target: android-x86_64
# host: ubuntu-latest
# flutter_version: '2.10.5'
# flutter_channel: 'stable'
runs-on: ${{ matrix.config.host }}
env:
TARGET: ${{ matrix.config.target }}
flutter_version: ${{ matrix.config.flutter_version }}
flutter_channel: ${{ matrix.config.flutter_channel }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- id: check_asset
name: Check asset
run: |
cd ci
cargo run --bin check-asset
- name: checkout core
if: steps.check_asset.outputs.skip_build != 'true'
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
repository: 'niuhuan/jasmine-rs-core'
path: 'native'
- name: Cache Flutter dependencies (Linux/Android)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.host == 'ubuntu-latest'
uses: actions/cache@v3
with:
path: /opt/hostedtoolcache/flutter
key: ${{ runner.os }}-flutter
- name: Setup flutter
if: steps.check_asset.outputs.skip_build != 'true'
uses: subosito/flutter-action@v2
with:
channel: ${{ env.flutter_channel }}
flutter-version: ${{ env.flutter_version }}
architecture: x64
- name: Install cargo tools (non-android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'macos' || matrix.config.target == 'windows' || matrix.config.target == 'linux' || matrix.config.target == 'ios' )
run: |
cargo install --force cbindgen
- name: Install cargo tools (Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' )
run: |
cargo install --force cargo-ndk
- name: Setup java (Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' )
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Setup android tools (Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' )
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 8512546
packages: 'platform-tools platforms;android-32 build-tools;30.0.2 ndk;23.1.7779620'
- name: Install libfuse2 (Linux)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'linux'
run: |
sudo apt update
sudo apt install -y libfuse2
- name: Set-Version (All)
if: steps.check_asset.outputs.skip_build != 'true'
run: |
cd ci
cp version.code.txt ../lib/assets/version.txt
- name: Sed old deps (Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.flutter_version == '2.10.5')
run: |
sed -i "s/another_xlider: ^1.0.1+2/another_xlider: 1.0.1+2/g" pubspec.yaml
sed -i "s/flutter_styled_toast: ^2.0.0/flutter_styled_toast: 2.0.0/g" pubspec.yaml
sed -i "s/filesystem_picker: ^3.1.0/filesystem_picker: 2.0.0/g" pubspec.yaml
sed -i "s/file_picker: 5.2.1/file_picker: 4.6.1/g" pubspec.yaml
sed -i "s/modal_bottom_sheet: ^3.0.0-pre/modal_bottom_sheet: ^2.0.0/g" pubspec.yaml
sed -i "s/window_manager: ^0.3.2//g" pubspec.yaml
echo > lib/basic/desktop.dart
sed -i 's/import '\''basic\/desktop.dart'\'';/\n/g' lib/main.dart
sed -i "s/onDesktopStart();//g" lib/main.dart
sed -i "s/onDesktopStop();//g" lib/main.dart
- name: Append application-identifier (ios)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'ios')
run: |
/usr/libexec/PlistBuddy -c 'Add :application-identifier string niuhuan.jasmine' ios/Runner/Info.plist
- name: Install rust target and build (ios)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'ios')
run: |
rustup target install aarch64-apple-ios
cargo build --manifest-path native/jmbackend/platforms/ios/Cargo.toml --features= --lib --release --target=aarch64-apple-ios
cp native/jmbackend/platforms/ios/target/aarch64-apple-ios/release/librust.a ios/
cbindgen native/jmbackend/src/lib.rs -l c > ios/rust.h
flutter build ios --no-simulator --no-codesign --release
cd build
rm -rf Payload
mkdir Payload
mv ios/iphoneos/Runner.app Payload/
sh ../scripts/thin-payload.sh Payload
zip -r -9 nosign.ipa Payload
cd ..
# if ios-sim
# cargo build --manifest-path native/jmbackend/platforms/ios-sim/Cargo.toml --features= --lib --release --target=aarch64-apple-ios-sim
# cargo build --manifest-path native/jmbackend/platforms/ios-sim/Cargo.toml --features= --lib --release --target=x86_64-apple-ios
# lipo -create -output ios/librust.a native/jmbackend/platforms/ios-sim/target/x86_64-apple-ios/release/librust.a native/jmbackend/platforms/ios-sim/target/aarch64-apple-ios-sim/release/librust.a
# cbindgen native/jmbackend/src/lib.rs -l c > ios/rust.h
- name: Install rust target and build (Android-arm64)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm64')
run: |
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ env.NDK_VERSION }}
rustup target install aarch64-linux-android
cd native/jmbackend/platforms/android
cargo ndk -o ../../../../android/app/src/main/jniLibs -t arm64-v8a build --release
cd ../../../..
flutter build apk --target-platform android-arm64
- name: Install rust target and build (Android-arm32)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32')
run: |
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ env.NDK_VERSION }}
rustup target install armv7-linux-androideabi
cd native/jmbackend/platforms/android
cargo ndk -o ../../../../android/app/src/main/jniLibs -t armeabi-v7a build --release
cd ../../../..
flutter build apk --target-platform android-arm
- name: Install rust target and build (Android-x86_64)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-x86_64')
run: |
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ env.NDK_VERSION }}
rustup target install x86_64-linux-android
cd native/jmbackend/platforms/android
cargo ndk -o ../../../../android/app/src/main/jniLibs -t x86_64 build --release
cd ../../../..
flutter build apk --target-platform android-x64
- name: Install dependencies and build (Linux)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'linux'
run: |
sudo apt-get update
sudo apt install -y ninja-build liblzma-dev libgtk-3-dev libgl1-mesa-dev xorg-dev
curl -JOL https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod a+x appimagetool-x86_64.AppImage
mv appimagetool-x86_64.AppImage appimagetool
cargo build --manifest-path native/jmbackend/platforms/linux/Cargo.toml --features= --lib --release --target=x86_64-unknown-linux-gnu
cp native/jmbackend/platforms/linux/target/x86_64-unknown-linux-gnu/release/librust.a linux/
cbindgen native/jmbackend/src/lib.rs -l c++ > linux/rust.h
cbindgen native/jmbackend/platforms/linux/src/lib.rs -l c++ > linux/rust1.h
flutter config --enable-linux-desktop
flutter build linux --release
mv build/linux/x64/release/bundle/{jasmine,AppRun}
cp linux/appimage/* build/linux/x64/release/bundle/
./appimagetool build/linux/x64/release/bundle/
mv *.AppImage build/linux.AppImage
- name: build (windows)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'windows'
run: |
cargo build --manifest-path native/jmbackend/platforms/windows/Cargo.toml --release --target x86_64-pc-windows-msvc
cp native/jmbackend/platforms/windows/target/x86_64-pc-windows-msvc/release/rust.lib windows/
cbindgen native/jmbackend/src/lib.rs -l c++ > windows/rust.h
flutter config --enable-windows-desktop
flutter build windows
cd build/windows/runner/Release
Compress-Archive * ../../../../build/windows.zip
cd ../../../..
- name: Build (macos)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.target == 'macos'
run: |
rustup target install x86_64-apple-darwin
rustup target install aarch64-apple-darwin
cargo build --manifest-path native/jmbackend/platforms/macos/Cargo.toml --release --target x86_64-apple-darwin
cargo build --manifest-path native/jmbackend/platforms/macos/Cargo.toml --release --target aarch64-apple-darwin
lipo -create -output macos/librust.a native/jmbackend/platforms/macos/target/x86_64-apple-darwin/release/librust.a native/jmbackend/platforms/macos/target/aarch64-apple-darwin/release/librust.a
cbindgen native/jmbackend/src/lib.rs -l c > macos/rust.h
flutter config --enable-macos-desktop
flutter build macos
cd build
mkdir appimage
mv macos/Build/Products/Release/jasmine.app appimage/
ln -sf /Applications appimage/
hdiutil create -volname jasmine -srcfolder appimage -ov -format UDBZ macos.dmg
cd ..
- name: Sign APK (Android)
if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' )
env:
KEY_FILE_BASE64: ${{ secrets.KEY_FILE_BASE64 }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
echo $KEY_FILE_BASE64 > key.jks.base64
base64 -d key.jks.base64 > key.jks
echo $KEY_PASSWORD | $ANDROID_HOME/build-tools/30.0.2/apksigner sign --ks key.jks build/app/outputs/flutter-apk/app-release.apk
- name: Upload Asset (All)
if: steps.check_asset.outputs.skip_build != 'true'
run: |
cd ci
cargo run --bin upload-asset
community_notify:
name: community notify
runs-on: ubuntu-latest
needs:
- build_release_assets
env:
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
TG_CHAT_IDS: ${{ secrets.TG_CHAT_IDS }}
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
DISCORD_CHAT_IDS: ${{ secrets.DISCORD_CHAT_IDS }}
steps:
- name: Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Checkout
uses: actions/checkout@v3
- run: |
cd ci
cargo run --bin community-notify