Skip to content

Commit 10cafad

Browse files
committed
Implement releases
1 parent 098a6af commit 10cafad

1 file changed

Lines changed: 228 additions & 20 deletions

File tree

.github/workflows/ci.yml

Lines changed: 228 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,86 @@ on: [push, pull_request]
33
name: CI
44

55
jobs:
6-
ci:
6+
build:
7+
name: ${{ matrix.name }}
78
runs-on: ${{ matrix.os }}
89
strategy:
10+
fail-fast: false
911
matrix:
10-
os: [windows-latest, ubuntu-latest, macos-latest]
11-
rust:
12-
- stable
13-
- beta
14-
- nightly
15-
- 1.86.0 # MSRV
12+
include:
13+
# MSRV builds
14+
- name: Windows - MSRV
15+
os: windows-latest
16+
rust: 1.86.0
17+
target: x86_64-pc-windows-msvc
18+
- name: Linux - MSRV
19+
os: ubuntu-latest
20+
rust: 1.86.0
21+
target: x86_64-unknown-linux-gnu
22+
- name: macOS - MSRV
23+
os: macos-latest
24+
rust: 1.86.0
25+
target: aarch64-apple-darwin
26+
# Beta builds
27+
- name: Windows - Beta
28+
os: windows-latest
29+
rust: beta
30+
target: x86_64-pc-windows-msvc
31+
- name: Linux - Beta
32+
os: ubuntu-latest
33+
rust: beta
34+
target: x86_64-unknown-linux-gnu
35+
- name: macOS - Beta
36+
os: macos-latest
37+
rust: beta
38+
target: aarch64-apple-darwin
39+
# Nightly builds
40+
- name: Windows - Nightly
41+
os: windows-latest
42+
rust: nightly
43+
target: x86_64-pc-windows-msvc
44+
- name: Linux - Nightly
45+
os: ubuntu-latest
46+
rust: nightly
47+
target: x86_64-unknown-linux-gnu
48+
- name: macOS - Nightly
49+
os: macos-latest
50+
rust: nightly
51+
target: aarch64-apple-darwin
52+
# Stable builds with artifact creation
53+
- name: Windows - Stable (x86_64)
54+
os: windows-latest
55+
rust: stable
56+
target: x86_64-pc-windows-msvc
57+
- name: Linux - Stable (x86_64)
58+
os: ubuntu-latest
59+
rust: stable
60+
target: x86_64-unknown-linux-gnu
61+
- name: macOS - Stable (aarch64)
62+
os: macos-latest
63+
rust: stable
64+
target: aarch64-apple-darwin
1665
steps:
1766
- name: Checkout
1867
uses: actions/checkout@v4
68+
- name: Install Rust toolchain
69+
uses: dtolnay/rust-toolchain@master
70+
with:
71+
toolchain: ${{ matrix.rust }}
72+
targets: ${{ matrix.target && format('{0},', matrix.target) || '' }}aarch64-linux-android,armv7-linux-androideabi
73+
components: rustfmt, clippy
74+
- name: Check code formatting
75+
run: cargo fmt --all -- --check
76+
- name: Run clippy
77+
run: cargo clippy -- -D warnings
1978
- name: Install MSYS (Windows only)
2079
if: runner.os == 'Windows'
2180
uses: msys2/setup-msys2@v2
2281
with:
2382
path-type: inherit
2483
msystem: UCRT64
25-
- name: Install Rust toolchain
26-
uses: dtolnay/rust-toolchain@master
27-
with:
28-
toolchain: ${{ matrix.rust }}
29-
targets: aarch64-linux-android, armv7-linux-androideabi
30-
components: rustfmt, clippy
3184
- name: Run build
32-
run: cargo install --locked --path .
85+
run: cargo install --locked --target ${{ matrix.target }} --path .
3386
- name: Smoke test `ndk-env`
3487
run: cargo ndk-env --target armeabi-v7a
3588
- name: Run basic example
@@ -44,9 +97,164 @@ jobs:
4497
if: runner.os != 'Windows'
4598
working-directory: example/openssl
4699
run: cargo ndk -t arm64-v8a --platform 28 build
47-
- name: Check code formatting
48-
continue-on-error: true
49-
run: cargo fmt --all -- --check
50-
- name: Run clippy
51-
continue-on-error: true
52-
run: cargo clippy -- -D warnings
100+
- name: Build release binary
101+
if: ${{ contains(matrix.name, 'Stable') }}
102+
run: cargo build --locked --release --target ${{ matrix.target }}
103+
- name: Get version
104+
if: ${{ contains(matrix.name, 'Stable') }}
105+
id: version
106+
shell: bash
107+
run: |
108+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
109+
VERSION="${GITHUB_REF#refs/tags/}"
110+
else
111+
VERSION=dev
112+
fi
113+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
114+
echo "ARTIFACT_NAME=${{ format('cargo-ndk-{0}', matrix.target) }}-$VERSION" >> $GITHUB_OUTPUT
115+
- name: Copy binary (Unix)
116+
if: ${{ runner.os != 'Windows' && contains(matrix.name, 'Stable') }}
117+
run: |
118+
mkdir ${{ steps.version.outputs.ARTIFACT_NAME }}
119+
for file in cargo-ndk cargo-ndk-env cargo-ndk-test cargo-ndk-runner; do
120+
cp target/${{ matrix.target }}/release/$file ${{ steps.version.outputs.ARTIFACT_NAME }}/$file
121+
done
122+
- name: Copy binary (Windows)
123+
if: ${{ runner.os == 'Windows' && contains(matrix.name, 'Stable') }}
124+
run: |
125+
mkdir ${{ steps.version.outputs.ARTIFACT_NAME }}
126+
foreach ($file in @('cargo-ndk.exe', 'cargo-ndk-env.exe', 'cargo-ndk-test.exe', 'cargo-ndk-runner.exe')) {
127+
Copy-Item "target/${{ matrix.target }}/release/$file" "${{ steps.version.outputs.ARTIFACT_NAME }}/$file"
128+
}
129+
- name: Create tar.gz archive (Unix)
130+
if: ${{ contains(matrix.name, 'Stable') && runner.os != 'Windows' }}
131+
run: |
132+
tar -cf ${{ steps.version.outputs.ARTIFACT_NAME }}.tar ${{ steps.version.outputs.ARTIFACT_NAME }}
133+
gzip -9 ${{ steps.version.outputs.ARTIFACT_NAME }}.tar
134+
mv ${{ steps.version.outputs.ARTIFACT_NAME }}{.tar.gz,.tgz}
135+
- name: Create zip archive (Windows)
136+
if: ${{ contains(matrix.name, 'Stable') && runner.os == 'Windows' }}
137+
run: |
138+
7z a -mx=9 ${{ steps.version.outputs.ARTIFACT_NAME }}.zip ${{ steps.version.outputs.ARTIFACT_NAME }}
139+
- name: Upload artifacts (Unix)
140+
uses: actions/upload-artifact@v4
141+
if: ${{ contains(matrix.name, 'Stable') && runner.os != 'Windows' }}
142+
with:
143+
compression-level: 0
144+
name: ${{ steps.version.outputs.ARTIFACT_NAME }}
145+
path: ${{ steps.version.outputs.ARTIFACT_NAME }}.tgz
146+
- name: Upload artifacts (Windows)
147+
uses: actions/upload-artifact@v4
148+
if: ${{ contains(matrix.name, 'Stable') && runner.os == 'Windows' }}
149+
with:
150+
compression-level: 0
151+
name: ${{ steps.version.outputs.ARTIFACT_NAME }}
152+
path: ${{ steps.version.outputs.ARTIFACT_NAME }}.zip
153+
build-non-host:
154+
name: ${{ matrix.name }}
155+
runs-on: ${{ matrix.os }}
156+
strategy:
157+
fail-fast: false
158+
matrix:
159+
include:
160+
- name: Windows - Stable (aarch64, non-host)
161+
os: windows-latest
162+
rust: stable
163+
target: aarch64-pc-windows-msvc
164+
- name: Linux - Stable (aarch64, non-host)
165+
os: ubuntu-latest
166+
rust: stable
167+
target: aarch64-unknown-linux-gnu
168+
cross: true
169+
- name: macOS - Stable (x86_64, non-host)
170+
os: macos-latest
171+
rust: stable
172+
target: x86_64-apple-darwin
173+
steps:
174+
- name: Checkout
175+
uses: actions/checkout@v4
176+
- name: Install Rust toolchain
177+
uses: dtolnay/rust-toolchain@master
178+
with:
179+
toolchain: ${{ matrix.rust }}
180+
targets: ${{ matrix.target }}
181+
- name: Set up cross compilation (Linux)
182+
if: matrix.cross
183+
run: |
184+
cargo install cross --git https://github.com/cross-rs/cross
185+
- name: Build release binary (native)
186+
if: ${{ !matrix.cross }}
187+
run: cargo build --locked --release --target ${{ matrix.target }}
188+
- name: Build release binary (cross)
189+
if: matrix.cross
190+
run: cross build --locked --release --target ${{ matrix.target }}
191+
- name: Get version
192+
id: version
193+
shell: bash
194+
run: |
195+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
196+
VERSION="${GITHUB_REF#refs/tags/}"
197+
else
198+
VERSION=dev
199+
fi
200+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
201+
echo "ARTIFACT_NAME=${{ format('cargo-ndk-{0}', matrix.target) }}-$VERSION" >> $GITHUB_OUTPUT
202+
- name: Copy binary (Unix)
203+
if: runner.os != 'Windows'
204+
run: |
205+
mkdir ${{ steps.version.outputs.ARTIFACT_NAME }}
206+
for file in cargo-ndk cargo-ndk-env cargo-ndk-test cargo-ndk-runner; do
207+
cp target/${{ matrix.target }}/release/$file ${{ steps.version.outputs.ARTIFACT_NAME }}/$file
208+
done
209+
- name: Copy binary (Windows)
210+
if: runner.os == 'Windows'
211+
run: |
212+
mkdir ${{ steps.version.outputs.ARTIFACT_NAME }}
213+
foreach ($file in @('cargo-ndk.exe', 'cargo-ndk-env.exe', 'cargo-ndk-test.exe', 'cargo-ndk-runner.exe')) {
214+
Copy-Item "target/${{ matrix.target }}/release/$file" "${{ steps.version.outputs.ARTIFACT_NAME }}/$file"
215+
}
216+
- name: Create tar.gz archive (Unix)
217+
if: runner.os != 'Windows'
218+
run: |
219+
tar -cf ${{ steps.version.outputs.ARTIFACT_NAME }}.tar ${{ steps.version.outputs.ARTIFACT_NAME }}
220+
gzip -9 ${{ steps.version.outputs.ARTIFACT_NAME }}.tar
221+
mv ${{ steps.version.outputs.ARTIFACT_NAME }}{.tar.gz,.tgz}
222+
- name: Create zip archive (Windows)
223+
if: runner.os == 'Windows'
224+
run: |
225+
7z a -mx=9 ${{ steps.version.outputs.ARTIFACT_NAME }}.zip ${{ steps.version.outputs.ARTIFACT_NAME }}
226+
- name: Upload artifacts (Unix)
227+
uses: actions/upload-artifact@v4
228+
if: runner.os != 'Windows'
229+
with:
230+
compression-level: 0
231+
name: ${{ steps.version.outputs.ARTIFACT_NAME }}
232+
path: ${{ steps.version.outputs.ARTIFACT_NAME }}.tgz
233+
- name: Upload artifacts (Windows)
234+
uses: actions/upload-artifact@v4
235+
if: runner.os == 'Windows'
236+
with:
237+
compression-level: 0
238+
name: ${{ steps.version.outputs.ARTIFACT_NAME }}
239+
path: ${{ steps.version.outputs.ARTIFACT_NAME }}.zip
240+
release:
241+
name: Create GitHub Release
242+
runs-on: ubuntu-latest
243+
needs: [build, build-non-host]
244+
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.')
245+
steps:
246+
- name: Download all artifacts
247+
uses: actions/download-artifact@v4
248+
with:
249+
path: artifacts
250+
- name: Unzip all the things
251+
run: |
252+
ls -l artifacts/*/*
253+
mv artifacts/*/* upload/
254+
ls -l upload
255+
- name: Create release
256+
uses: softprops/action-gh-release@v2
257+
with:
258+
files: upload/*
259+
generate_release_notes: true
260+
prerelease: ${{ contains(github.ref, '-') }}

0 commit comments

Comments
 (0)