@@ -3,7 +3,7 @@ on: [push, pull_request]
33name : CI
44
55jobs :
6- ci :
6+ build :
77 name : ${{ matrix.name }}
88 runs-on : ${{ matrix.os }}
99 strategy :
@@ -16,33 +16,16 @@ jobs:
1616 rust : stable
1717 target : x86_64-pc-windows-msvc
1818 artifact_name : cargo-ndk_windows_x86_64
19- - name : Windows - Stable (aarch64)
20- os : windows-latest
21- rust : stable
22- target : aarch64-pc-windows-msvc
23- artifact_name : cargo-ndk_windows_arm64
2419 - name : Linux - Stable (x86_64)
2520 os : ubuntu-latest
2621 rust : stable
2722 target : x86_64-unknown-linux-gnu
2823 artifact_name : cargo-ndk_linux_x86_64
29- - name : Linux - Stable (aarch64)
30- os : ubuntu-latest
31- rust : stable
32- target : aarch64-unknown-linux-gnu
33- artifact_name : cargo-ndk_linux_aarch64
34- cross : true
35- non_host : true
3624 - name : macOS - Stable (x86_64)
3725 os : macos-latest
3826 rust : stable
3927 target : x86_64-apple-darwin
4028 artifact_name : cargo-ndk_macos_x86_64
41- - name : macOS - Stable (aarch64)
42- os : macos-latest
43- rust : stable
44- target : aarch64-apple-darwin
45- artifact_name : cargo-ndk_macos_aarch64
4629 # MSRV builds
4730 - name : Windows - MSRV
4831 os : windows-latest
@@ -82,38 +65,32 @@ jobs:
8265 toolchain : ${{ matrix.rust }}
8366 targets : ${{ matrix.target && format('{0},', matrix.target) || '' }}aarch64-linux-android,armv7-linux-androideabi
8467 components : rustfmt, clippy
68+ - name : Check code formatting
69+ run : cargo fmt --all -- --check
70+ - name : Run clippy
71+ run : cargo clippy -- -D warnings
8572 - name : Install MSYS (Windows only)
86- if : runner.os == 'Windows' && !matrix.non_host
73+ if : runner.os == 'Windows'
8774 uses : msys2/setup-msys2@v2
8875 with :
8976 path-type : inherit
9077 msystem : UCRT64
9178 - name : Run build
92- if : ' !matrix.non_host'
93- run : cargo install --locked --path .
79+ run : cargo install --locked --target ${{ matrix.target }} --path .
9480 - name : Smoke test `ndk-env`
95- if : ' !matrix.non_host'
9681 run : cargo ndk-env --target armeabi-v7a
9782 - name : Run basic example
98- if : ' !matrix.non_host'
9983 working-directory : example/basic
10084 run : cargo ndk -t armeabi-v7a -o jniLibs build
10185 - name : Run openssl example (Windows)
102- if : runner.os == 'Windows' && !matrix.non_host
86+ if : runner.os == 'Windows'
10387 shell : ' msys2 {0}'
10488 working-directory : example/openssl
10589 run : cargo ndk -t arm64-v8a --platform 28 build
10690 - name : Run openssl example (Unix)
107- if : runner.os != 'Windows' && !matrix.non_host
91+ if : runner.os != 'Windows'
10892 working-directory : example/openssl
10993 run : cargo ndk -t arm64-v8a --platform 28 build
110- - name : Check code formatting
111- if : ' !matrix.non_host'
112- continue-on-error : true
113- run : cargo fmt --all -- --check
114- - name : Run clippy
115- if : ' !matrix.non_host'
116- run : cargo clippy -- -D warnings
11794 - name : Get version
11895 if : matrix.target
11996 id : version
@@ -124,16 +101,9 @@ jobs:
124101 else
125102 echo "VERSION=dev" >> $GITHUB_OUTPUT
126103 fi
127- - name : Set up cross compilation (Linux)
128- if : matrix.cross
129- run : |
130- cargo install cross --git https://github.com/cross-rs/cross
131- - name : Build release binary (native)
132- if : matrix.target && !matrix.cross
133- run : cargo build --release --target ${{ matrix.target }}
134- - name : Build release binary (cross)
135- if : matrix.target && matrix.cross
136- run : cross build --release --target ${{ matrix.target }}
104+ - name : Build release binary
105+ if : matrix.target
106+ run : cargo build --locked --release --target ${{ matrix.target }}
137107 - name : Copy binary (Unix)
138108 if : matrix.target && runner.os != 'Windows'
139109 run : |
@@ -171,10 +141,97 @@ jobs:
171141 with :
172142 name : ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}
173143 path : ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.zip
144+ build-non-host :
145+ name : ${{ matrix.name }}
146+ runs-on : ${{ matrix.os }}
147+ strategy :
148+ fail-fast : false
149+ matrix :
150+ include :
151+ - name : Windows - Stable (aarch64)
152+ os : windows-latest
153+ rust : stable
154+ target : aarch64-pc-windows-msvc
155+ artifact_name : cargo-ndk_windows_arm64
156+ - name : Linux - Stable (aarch64)
157+ os : ubuntu-latest
158+ rust : stable
159+ target : aarch64-unknown-linux-gnu
160+ artifact_name : cargo-ndk_linux_aarch64
161+ cross : true
162+ - name : macOS - Stable (aarch64)
163+ os : macos-latest
164+ rust : stable
165+ target : aarch64-apple-darwin
166+ artifact_name : cargo-ndk_macos_aarch64
167+ steps :
168+ - name : Checkout
169+ uses : actions/checkout@v4
170+ - name : Install Rust toolchain
171+ uses : dtolnay/rust-toolchain@master
172+ with :
173+ toolchain : ${{ matrix.rust }}
174+ targets : ${{ matrix.target }}
175+ - name : Set up cross compilation (Linux)
176+ if : matrix.cross
177+ run : |
178+ cargo install cross --git https://github.com/cross-rs/cross
179+ - name : Build release binary (native)
180+ if : ' !matrix.cross'
181+ run : cargo build --locked --release --target ${{ matrix.target }}
182+ - name : Build release binary (cross)
183+ if : matrix.cross
184+ run : cross build --locked --release --target ${{ matrix.target }}
185+ - name : Get version
186+ id : version
187+ shell : bash
188+ run : |
189+ if [[ "$GITHUB_REF" == refs/tags/* ]]; then
190+ echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
191+ else
192+ echo "VERSION=dev" >> $GITHUB_OUTPUT
193+ fi
194+ - name : Copy binary (Unix)
195+ if : runner.os != 'Windows'
196+ run : |
197+ mkdir artifacts
198+ for file in cargo-ndk cargo-ndk-env cargo-ndk-test cargo-ndk-runner; do
199+ cp target/${{ matrix.target }}/release/$file artifacts/$file
200+ done
201+ - name : Copy binary (Windows)
202+ if : runner.os == 'Windows'
203+ run : |
204+ mkdir artifacts
205+ for ($file in @('cargo-ndk.exe', 'cargo-ndk-env.exe', 'cargo-ndk-test.exe', 'cargo-ndk-runner.exe')) {
206+ Copy-Item "target/${{ matrix.target }}/release/$file" "artifacts/$file"
207+ }
208+ - name : Create tar.gz archive (Unix)
209+ if : runner.os != 'Windows'
210+ run : |
211+ cd artifacts
212+ tar -cf ../${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.tar *
213+ gzip -9 ../${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.tar
214+ - name : Create zip archive (Windows)
215+ if : runner.os == 'Windows'
216+ run : |
217+ cd artifacts
218+ 7z a -mx=9 ../${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.zip *
219+ - name : Upload artifacts (Unix)
220+ uses : actions/upload-artifact@v4
221+ if : runner.os != 'Windows'
222+ with :
223+ name : ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}
224+ path : ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.tar.gz
225+ - name : Upload artifacts (Windows)
226+ uses : actions/upload-artifact@v4
227+ if : runner.os == 'Windows'
228+ with :
229+ name : ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}
230+ path : ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.zip
174231 release :
175232 name : Create GitHub Release
176233 runs-on : ubuntu-latest
177- needs : ci
234+ needs : [ci, build-non-host]
178235 if : startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.')
179236 steps :
180237 - name : Download all artifacts
0 commit comments