77 runs-on : ${{ matrix.os }}
88 strategy :
99 matrix :
10- os : [windows-latest, ubuntu-latest, macos-latest]
11- rust :
12- - stable
13- - beta
14- - nightly
15- - 1.86.0 # MSRV
10+ include :
11+ # Regular CI matrix for all Rust versions
12+ - os : windows-latest
13+ rust : stable
14+ - os : windows-latest
15+ rust : beta
16+ - os : windows-latest
17+ rust : nightly
18+ - os : windows-latest
19+ rust : 1.86.0 # MSRV
20+ - os : ubuntu-latest
21+ rust : stable
22+ - os : ubuntu-latest
23+ rust : beta
24+ - os : ubuntu-latest
25+ rust : nightly
26+ - os : ubuntu-latest
27+ rust : 1.86.0 # MSRV
28+ - os : macos-latest
29+ rust : stable
30+ - os : macos-latest
31+ rust : beta
32+ - os : macos-latest
33+ rust : nightly
34+ - os : macos-latest
35+ rust : 1.86.0 # MSRV
36+ # Release artifact builds (stable only, with targets)
37+ - os : ubuntu-latest
38+ rust : stable
39+ target : x86_64-unknown-linux-gnu
40+ artifact_name : cargo-ndk_linux_x86_64
41+ - os : ubuntu-latest
42+ rust : stable
43+ target : aarch64-unknown-linux-gnu
44+ artifact_name : cargo-ndk_linux_aarch64
45+ - os : macos-latest
46+ rust : stable
47+ target : x86_64-apple-darwin
48+ artifact_name : cargo-ndk_macos_x86_64
49+ - os : macos-latest
50+ rust : stable
51+ target : aarch64-apple-darwin
52+ artifact_name : cargo-ndk_macos_aarch64
53+ - os : windows-latest
54+ rust : stable
55+ target : x86_64-pc-windows-msvc
56+ artifact_name : cargo-ndk_windows_x86_64
57+ - os : windows-latest
58+ rust : stable
59+ target : aarch64-pc-windows-msvc
60+ artifact_name : cargo-ndk_windows_arm64
1661 steps :
1762 - name : Checkout
1863 uses : actions/checkout@v4
2671 uses : dtolnay/rust-toolchain@master
2772 with :
2873 toolchain : ${{ matrix.rust }}
29- targets : aarch64-linux-android, armv7-linux-androideabi
74+ targets : ${{ matrix.target && matrix.target || ' aarch64-linux-android,armv7-linux-androideabi' }}
3075 components : rustfmt, clippy
76+ - name : Install cross-compilation dependencies (Linux aarch64)
77+ if : matrix.target == 'aarch64-unknown-linux-gnu'
78+ run : |
79+ sudo apt-get update
80+ sudo apt-get install -y gcc-aarch64-linux-gnu
3181 - name : Run build
3282 run : cargo install --locked --path .
3383 - name : Smoke test `ndk-env`
@@ -50,86 +100,50 @@ jobs:
50100 - name : Run clippy
51101 continue-on-error : true
52102 run : cargo clippy -- -D warnings
53-
54- build :
55- name : Build binaries
56- runs-on : ${{ matrix.os }}
57- strategy :
58- matrix :
59- include :
60- # Linux targets
61- - os : ubuntu-latest
62- target : x86_64-unknown-linux-gnu
63- artifact_name : cargo-ndk_linux_x86_64
64- - os : ubuntu-latest
65- target : aarch64-unknown-linux-gnu
66- artifact_name : cargo-ndk_linux_aarch64
67- # macOS targets
68- - os : macos-latest
69- target : x86_64-apple-darwin
70- artifact_name : cargo-ndk_macos_x86_64
71- - os : macos-latest
72- target : aarch64-apple-darwin
73- artifact_name : cargo-ndk_macos_aarch64
74- # Windows targets
75- - os : windows-latest
76- target : x86_64-pc-windows-msvc
77- artifact_name : cargo-ndk_windows_x86_64
78- - os : windows-latest
79- target : aarch64-pc-windows-msvc
80- artifact_name : cargo-ndk_windows_arm64
81- steps :
82- - name : Checkout
83- uses : actions/checkout@v4
84- - name : Install Rust toolchain
85- uses : dtolnay/rust-toolchain@stable
86- with :
87- targets : ${{ matrix.target }}
88- - name : Install cross-compilation dependencies (Linux aarch64)
89- if : matrix.target == 'aarch64-unknown-linux-gnu'
90- run : |
91- sudo apt-get update
92- sudo apt-get install -y gcc-aarch64-linux-gnu
93- - name : Build binary
103+ # Artifact creation steps (only for release builds with targets)
104+ - name : Build release binary
105+ if : matrix.target
94106 run : cargo build --release --target ${{ matrix.target }}
95107 - name : Create artifact directory
108+ if : matrix.target
96109 run : mkdir -p artifacts
97110 - name : Copy binary (Unix)
98- if : runner.os != 'Windows'
111+ if : matrix.target && runner.os != 'Windows'
99112 run : |
100113 cp target/${{ matrix.target }}/release/cargo-ndk artifacts/cargo-ndk
101114 cp target/${{ matrix.target }}/release/cargo-ndk-env artifacts/cargo-ndk-env
102115 cp target/${{ matrix.target }}/release/cargo-ndk-test artifacts/cargo-ndk-test
103116 cp target/${{ matrix.target }}/release/cargo-ndk-runner artifacts/cargo-ndk-runner
104117 - name : Copy binary (Windows)
105- if : runner.os == 'Windows'
118+ if : matrix.target && runner.os == 'Windows'
106119 run : |
107120 cp target/${{ matrix.target }}/release/cargo-ndk.exe artifacts/cargo-ndk.exe
108121 cp target/${{ matrix.target }}/release/cargo-ndk-env.exe artifacts/cargo-ndk-env.exe
109122 cp target/${{ matrix.target }}/release/cargo-ndk-test.exe artifacts/cargo-ndk-test.exe
110123 cp target/${{ matrix.target }}/release/cargo-ndk-runner.exe artifacts/cargo-ndk-runner.exe
111124 - name : Get version
125+ if : matrix.target
112126 id : version
113127 run : echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
114128 - name : Create tar.gz archive (Unix)
115- if : runner.os != 'Windows'
129+ if : matrix.target && runner.os != 'Windows'
116130 run : |
117131 cd artifacts
118132 tar -czf ../${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.tar.gz *
119133 - name : Create zip archive (Windows)
120- if : runner.os == 'Windows'
134+ if : matrix.target && runner.os == 'Windows'
121135 run : |
122136 cd artifacts
123137 7z a -mx=9 ../${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.zip *
124138 - name : Upload artifacts (Unix)
125139 uses : actions/upload-artifact@v4
126- if : runner.os != 'Windows' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.')
140+ if : matrix.target && runner.os != 'Windows' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.')
127141 with :
128142 name : ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}
129143 path : ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.tar.gz
130144 - name : Upload artifacts (Windows)
131145 uses : actions/upload-artifact@v4
132- if : runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.')
146+ if : matrix.target && runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.')
133147 with :
134148 name : ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}
135149 path : ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.zip
0 commit comments