more #201
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: [push, pull_request] | |
| name: CI | |
| jobs: | |
| ci: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| # Regular CI matrix for all Rust versions | |
| - os: windows-latest | |
| rust: stable | |
| - os: windows-latest | |
| rust: beta | |
| - os: windows-latest | |
| rust: nightly | |
| - os: windows-latest | |
| rust: 1.86.0 # MSRV | |
| - os: ubuntu-latest | |
| rust: stable | |
| - os: ubuntu-latest | |
| rust: beta | |
| - os: ubuntu-latest | |
| rust: nightly | |
| - os: ubuntu-latest | |
| rust: 1.86.0 # MSRV | |
| - os: macos-latest | |
| rust: stable | |
| - os: macos-latest | |
| rust: beta | |
| - os: macos-latest | |
| rust: nightly | |
| - os: macos-latest | |
| rust: 1.86.0 # MSRV | |
| # Release artifact builds (stable only, with targets) | |
| - os: ubuntu-latest | |
| rust: stable | |
| target: x86_64-unknown-linux-gnu | |
| artifact_name: cargo-ndk_linux_x86_64 | |
| - os: ubuntu-latest | |
| rust: stable | |
| target: aarch64-unknown-linux-gnu | |
| artifact_name: cargo-ndk_linux_aarch64 | |
| - os: macos-latest | |
| rust: stable | |
| target: x86_64-apple-darwin | |
| artifact_name: cargo-ndk_macos_x86_64 | |
| - os: macos-latest | |
| rust: stable | |
| target: aarch64-apple-darwin | |
| artifact_name: cargo-ndk_macos_aarch64 | |
| - os: windows-latest | |
| rust: stable | |
| target: x86_64-pc-windows-msvc | |
| artifact_name: cargo-ndk_windows_x86_64 | |
| - os: windows-latest | |
| rust: stable | |
| target: aarch64-pc-windows-msvc | |
| artifact_name: cargo-ndk_windows_arm64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install MSYS (Windows only) | |
| if: runner.os == 'Windows' | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| path-type: inherit | |
| msystem: UCRT64 | |
| - 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: Install cross-compilation dependencies (Linux aarch64) | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Run build | |
| run: cargo install --locked --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: Check code formatting | |
| continue-on-error: true | |
| run: cargo fmt --all -- --check | |
| - name: Run clippy | |
| continue-on-error: true | |
| run: cargo clippy -- -D warnings | |
| # Artifact creation steps (only for release builds with targets) | |
| - name: Build release binary | |
| if: matrix.target | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Create artifact directory | |
| if: matrix.target | |
| run: mkdir -p artifacts | |
| - name: Copy binary (Unix) | |
| if: matrix.target && runner.os != 'Windows' | |
| run: | | |
| cp target/${{ matrix.target }}/release/cargo-ndk artifacts/cargo-ndk | |
| cp target/${{ matrix.target }}/release/cargo-ndk-env artifacts/cargo-ndk-env | |
| cp target/${{ matrix.target }}/release/cargo-ndk-test artifacts/cargo-ndk-test | |
| cp target/${{ matrix.target }}/release/cargo-ndk-runner artifacts/cargo-ndk-runner | |
| - name: Copy binary (Windows) | |
| if: matrix.target && runner.os == 'Windows' | |
| run: | | |
| cp target/${{ matrix.target }}/release/cargo-ndk.exe artifacts/cargo-ndk.exe | |
| cp target/${{ matrix.target }}/release/cargo-ndk-env.exe artifacts/cargo-ndk-env.exe | |
| cp target/${{ matrix.target }}/release/cargo-ndk-test.exe artifacts/cargo-ndk-test.exe | |
| cp target/${{ matrix.target }}/release/cargo-ndk-runner.exe artifacts/cargo-ndk-runner.exe | |
| - name: Get version | |
| if: matrix.target | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Create tar.gz archive (Unix) | |
| if: matrix.target && runner.os != 'Windows' | |
| run: | | |
| cd artifacts | |
| tar -czf ../${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.tar.gz * | |
| - name: Create zip archive (Windows) | |
| if: matrix.target && runner.os == 'Windows' | |
| run: | | |
| cd artifacts | |
| 7z a -mx=9 ../${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.zip * | |
| - name: Upload artifacts (Unix) | |
| uses: actions/upload-artifact@v4 | |
| if: matrix.target && runner.os != 'Windows' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.') | |
| with: | |
| name: ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }} | |
| path: ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.tar.gz | |
| - name: Upload artifacts (Windows) | |
| uses: actions/upload-artifact@v4 | |
| if: matrix.target && runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.') | |
| with: | |
| name: ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }} | |
| path: ${{ matrix.artifact_name }}_${{ steps.version.outputs.VERSION }}.zip |