-
Notifications
You must be signed in to change notification settings - Fork 12
173 lines (155 loc) · 4.99 KB
/
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
---
on:
push:
branches:
- master
pull_request:
jobs:
build-app:
name: Build app
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: true
- name: Validate gradle wrapper checksum
uses: gradle/actions/wrapper-validation@v3
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
cache: gradle
- name: Install cargo-android
shell: bash
run: |
cargo install \
--git https://github.com/chenxiaolong/cargo-android \
--tag v0.1.3
- name: Install toolchains
shell: bash
run: |
rustup target add aarch64-linux-android
rustup target add x86_64-linux-android
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
# We currently use the old eagerly evaluated android.ndkDirectory value in
# app/build.gradle.kts instead of the new lazily evaluated
# androidComponents.sdkComponents.ndkDirectory because the latter doesn't
# actually work (provider contains no value). However, because of this,
# AGP's automatic NDK installation breaks, so we need to manually install
# it here.
- name: Install Android NDK
shell: bash
run: |
set +o pipefail
version=$(sed -nr -e 's/^\s*ndkVersion\s*=\s"(.+)".*$/\1/p' app/build.gradle.kts)
yes | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "ndk;${version}"
- name: Build and test
# Debug build only since release builds require a signing key
run: ./gradlew --no-daemon build zipDebug -x assembleRelease
build-tool:
name: Build custota-tool
runs-on: ${{ matrix.artifact.os }}
env:
CARGO_TERM_COLOR: always
# https://github.com/rust-lang/rust/issues/78210
RUSTFLAGS: -C strip=symbols -C target-feature=+crt-static
TARGETS: ${{ join(matrix.artifact.targets, ' ') || matrix.artifact.name }}
ANDROID_API: ${{ matrix.artifact.android_api }}
strategy:
fail-fast: false
matrix:
artifact:
- os: ubuntu-latest
name: x86_64-unknown-linux-gnu
- os: windows-latest
name: x86_64-pc-windows-msvc
- os: macos-latest
name: universal-apple-darwin
targets:
- aarch64-apple-darwin
- x86_64-apple-darwin
combine: lipo
- os: ubuntu-latest
name: aarch64-linux-android31
targets:
- aarch64-linux-android
android_api: '31'
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
# For git describe
fetch-depth: 0
- name: Install cargo-android
shell: bash
run: |
cargo install \
--git https://github.com/chenxiaolong/cargo-android \
--tag v0.1.3
- name: Get version
id: get_version
shell: bash
run: |
echo -n 'version=' >> "${GITHUB_OUTPUT}"
git describe --always \
| sed -E "s/^v//g;s/([^-]*-g)/r\1/;s/-/./g" \
>> "${GITHUB_OUTPUT}"
- name: Install toolchains
shell: bash
run: |
for target in ${TARGETS}; do
rustup target add "${target}"
done
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.artifact.name }}
- name: Clippy
shell: bash
run: |
for target in ${TARGETS}; do
cargo android \
clippy --release --features static \
--target "${target}"
done
- name: Formatting
run: cargo fmt -- --check
- name: Build
shell: bash
run: |
for target in ${TARGETS}; do
cargo android \
build --release --features static \
--target "${target}"
done
- name: Create output directory
shell: bash
run: |
rm -rf target/output
case "${{ matrix.artifact.combine }}" in
lipo)
mkdir target/output
cmd=(lipo -output target/output/custota-tool -create)
for target in ${TARGETS}; do
cmd+=("target/${target}/release/custota-tool")
done
"${cmd[@]}"
;;
'')
ln -s "${TARGETS}/release" target/output
;;
*)
echo >&2 "Unsupported combine argument"
exit 1
;;
esac
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: custota-tool-${{ steps.get_version.outputs.version }}-${{ matrix.artifact.name }}
path: |
target/output/custota-tool
target/output/custota-tool.exe