-
Notifications
You must be signed in to change notification settings - Fork 86
261 lines (259 loc) · 9.72 KB
/
Copy pathci.yml
File metadata and controls
261 lines (259 loc) · 9.72 KB
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
on: [push, pull_request]
name: CI
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# MSRV builds
- name: Windows - MSRV
os: windows-latest
rust: 1.86.0
target: x86_64-pc-windows-msvc
- name: Linux - MSRV
os: ubuntu-latest
rust: 1.86.0
target: x86_64-unknown-linux-gnu
- name: macOS - MSRV
os: macos-latest
rust: 1.86.0
target: aarch64-apple-darwin
# Beta builds
- name: Windows - Beta
os: windows-latest
rust: beta
target: x86_64-pc-windows-msvc
- name: Linux - Beta
os: ubuntu-latest
rust: beta
target: x86_64-unknown-linux-gnu
- name: macOS - Beta
os: macos-latest
rust: beta
target: aarch64-apple-darwin
# Nightly builds
- name: Windows - Nightly
os: windows-latest
rust: nightly
target: x86_64-pc-windows-msvc
- name: Linux - Nightly
os: ubuntu-latest
rust: nightly
target: x86_64-unknown-linux-gnu
- name: macOS - Nightly
os: macos-latest
rust: nightly
target: aarch64-apple-darwin
# Stable builds with artifact creation
- name: Windows - Stable (x86_64)
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
- name: Linux - Stable (x86_64)
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
- name: macOS - Stable (aarch64)
os: macos-latest
rust: stable
target: aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target && format('{0},', matrix.target) || '' }}aarch64-linux-android,armv7-linux-androideabi
components: rustfmt, clippy
- name: Check code formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Install MSYS (Windows only)
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
path-type: inherit
msystem: UCRT64
- name: Run build
run: cargo install --locked --target ${{ matrix.target }} --path .
- name: Smoke test `ndk-env`
run: cargo ndk-env --target armeabi-v7a
- name: Run basic example
working-directory: example/basic
run: cargo ndk -t armeabi-v7a -o jniLibs build
- name: Run openssl example (Windows)
if: runner.os == 'Windows'
shell: 'msys2 {0}'
working-directory: example/openssl
run: cargo ndk -t arm64-v8a --platform 28 build
- name: Run openssl example (Unix)
if: runner.os != 'Windows'
working-directory: example/openssl
run: cargo ndk -t arm64-v8a --platform 28 build
- name: Get version
id: version
shell: bash
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
else
VERSION=dev
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "ARTIFACT_NAME=${{ format('cargo-ndk-{0}', matrix.target) }}-$VERSION" >> $GITHUB_OUTPUT
- name: Build release binary
run: cargo build --locked --release --target ${{ matrix.target }}
- name: Copy binary (Unix)
if: runner.os != 'Windows'
run: |
mkdir ${{ steps.version.outputs.ARTIFACT_NAME }}
for file in cargo-ndk cargo-ndk-env cargo-ndk-test cargo-ndk-runner; do
cp target/${{ matrix.target }}/release/$file ${{ steps.version.outputs.ARTIFACT_NAME }}/$file
done
- name: Copy binary (Windows)
if: runner.os == 'Windows'
run: |
mkdir ${{ steps.version.outputs.ARTIFACT_NAME }}
foreach ($file in @('cargo-ndk.exe', 'cargo-ndk-env.exe', 'cargo-ndk-test.exe', 'cargo-ndk-runner.exe')) {
Copy-Item "target/${{ matrix.target }}/release/$file" "${{ steps.version.outputs.ARTIFACT_NAME }}/$file"
}
- name: Create tar.gz archive (Unix)
if: runner.os != 'Windows'
run: |
tar -cf ${{ steps.version.outputs.ARTIFACT_NAME }}.tar ${{ steps.version.outputs.ARTIFACT_NAME }}
gzip -9 ${{ steps.version.outputs.ARTIFACT_NAME }}.tar
mv ${{ steps.version.outputs.ARTIFACT_NAME }}{.tar.gz,.tgz}
- name: Create zip archive (Windows)
if: runner.os == 'Windows'
run: |
7z a -mx=9 ${{ steps.version.outputs.ARTIFACT_NAME }}.zip ${{ steps.version.outputs.ARTIFACT_NAME }}
- name: Upload artifacts (Unix)
uses: actions/upload-artifact@v4
if: runner.os != 'Windows'
with:
compression-level: 0
name: ${{ steps.version.outputs.ARTIFACT_NAME }}
path: ${{ steps.version.outputs.ARTIFACT_NAME }}.tgz
- name: Upload artifacts (Windows)
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
compression-level: 0
name: ${{ steps.version.outputs.ARTIFACT_NAME }}
path: ${{ steps.version.outputs.ARTIFACT_NAME }}.zip
build-non-host:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Windows - Stable (aarch64, non-host)
os: windows-latest
rust: stable
target: aarch64-pc-windows-msvc
- name: Linux - Stable (aarch64, non-host)
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-gnu
cross: true
- name: macOS - Stable (x86_64, non-host)
os: macos-latest
rust: stable
target: x86_64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- name: Set up cross compilation (Linux)
if: matrix.cross
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: Build release binary (native)
if: '!matrix.cross'
run: cargo build --locked --release --target ${{ matrix.target }}
- name: Build release binary (cross)
if: matrix.cross
run: cross build --locked --release --target ${{ matrix.target }}
- name: Get version
id: version
shell: bash
run: |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
else
VERSION=dev
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "ARTIFACT_NAME=${{ format('cargo-ndk-{0}', matrix.target) }}-$VERSION" >> $GITHUB_OUTPUT
- name: Build release binary
run: cargo build --locked --release --target ${{ matrix.target }}
- name: Copy binary (Unix)
if: runner.os != 'Windows'
run: |
mkdir ${{ steps.version.outputs.ARTIFACT_NAME }}
for file in cargo-ndk cargo-ndk-env cargo-ndk-test cargo-ndk-runner; do
cp target/${{ matrix.target }}/release/$file ${{ steps.version.outputs.ARTIFACT_NAME }}/$file
done
- name: Copy binary (Windows)
if: runner.os == 'Windows'
run: |
mkdir ${{ steps.version.outputs.ARTIFACT_NAME }}
foreach ($file in @('cargo-ndk.exe', 'cargo-ndk-env.exe', 'cargo-ndk-test.exe', 'cargo-ndk-runner.exe')) {
Copy-Item "target/${{ matrix.target }}/release/$file" "${{ steps.version.outputs.ARTIFACT_NAME }}/$file"
}
- name: Create tar.gz archive (Unix)
if: runner.os != 'Windows'
run: |
tar -cf ${{ steps.version.outputs.ARTIFACT_NAME }}.tar ${{ steps.version.outputs.ARTIFACT_NAME }}
gzip -9 ${{ steps.version.outputs.ARTIFACT_NAME }}.tar
mv ${{ steps.version.outputs.ARTIFACT_NAME }}{.tar.gz,.tgz}
- name: Create zip archive (Windows)
if: runner.os == 'Windows'
run: |
7z a -mx=9 ${{ steps.version.outputs.ARTIFACT_NAME }}.zip ${{ steps.version.outputs.ARTIFACT_NAME }}
- name: Upload artifacts (Unix)
uses: actions/upload-artifact@v4
if: runner.os != 'Windows'
with:
compression-level: 0
name: ${{ steps.version.outputs.ARTIFACT_NAME }}
path: ${{ steps.version.outputs.ARTIFACT_NAME }}.tgz
- name: Upload artifacts (Windows)
uses: actions/upload-artifact@v4
if: runner.os == 'Windows'
with:
compression-level: 0
name: ${{ steps.version.outputs.ARTIFACT_NAME }}
path: ${{ steps.version.outputs.ARTIFACT_NAME }}.zip
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build, build-non-host]
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Unzip all the things
run: |
for file in artifacts/*.zip; do
unzip "$file" -d upload/
done
ls -l upload/
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: upload/*
generate_release_notes: true
prerelease: ${{ contains(github.ref, '-') }}