-
Notifications
You must be signed in to change notification settings - Fork 39
165 lines (132 loc) · 4.87 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
name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build-native-libs:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- android-abi: arm64-v8a
rust-target: aarch64-linux-android
- android-abi: armeabi-v7a
rust-target: armv7-linux-androideabi
- android-abi: x86_64
rust-target: x86_64-linux-android
- android-abi: x86
rust-target: i686-linux-android
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.rust-target }}
- name: Cache Cargo output
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ matrix.rust-target }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install cargo-ndk
run: cargo install cargo-ndk
- name: Build native libs
run: |
unset ANDROID_SDK_ROOT # Deprecated, will cause an error if left set.
cargo ndk --bindgen --target ${{ matrix.android-abi }} --platform 26 -o jniLibs build --release --features jpegxr
- uses: actions/upload-artifact@v4
with:
name: native-lib-${{ matrix.android-abi }}
path: jniLibs
build-apks:
needs: build-native-libs
runs-on: ubuntu-latest
env:
KEYSTORE: ${{ secrets.KEYSTORE }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with: # no name set, so all artifacts are downloaded
path: native-libs
- name: Copy native libs
run: |
mkdir app/src/main/jniLibs
cp -r native-libs/*/* app/src/main/jniLibs/
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Decode keystore
if: ${{ env.KEYSTORE != '' }}
run: echo $KEYSTORE | base64 -di > app/androidkey.jks
- name: Generate dummy keystore
if: ${{ env.KEYSTORE == '' }}
run: |
keytool -genkeypair -v -keystore app/androidkey.jks -alias dummy_alias \
-storepass dummy_pass -keypass dummy_pass -keyalg RSA -keysize 2048 -validity 10000 \
-dname "CN=example, OU=example, O=example, L=example, S=example, C=example"
echo 'SIGNING_KEY_ALIAS=dummy_alias' >> $GITHUB_ENV
echo 'SIGNING_STORE_PASSWORD=dummy_pass' >> $GITHUB_ENV
echo 'SIGNING_KEY_PASSWORD=dummy_pass' >> $GITHUB_ENV
- name: Build release APK
env:
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS || env.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD || env.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD || env.SIGNING_STORE_PASSWORD }}
run: ./gradlew assembleRelease
- uses: actions/upload-artifact@v4
with:
name: ruffle-release-apks
path: app/build/outputs/apk/release/*.apk
android-tests:
name: Android Tests
needs: build-native-libs
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [26, 35]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with: # no name set, so all artifacts are downloaded
path: native-libs
- name: Copy native libs
run: |
mkdir app/src/main/jniLibs
cp -r native-libs/*/* app/src/main/jniLibs/
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
script: |
adb shell settings put secure immersive_mode_confirmations confirmed
./gradlew connectedCheck
- name: Upload Test Report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }} # always run even if the previous step fails
with:
name: junit-test-results-${{ matrix.api-level }}
path: '**/build/outputs/**/TEST-*.xml'
retention-days: 1