ci: cross-platform release #46
Workflow file for this run
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
| name: Prototype continuous integration | |
| on: | |
| push: | |
| pull_request: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build_and_test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| toolchain: | |
| - stable | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} | |
| - run: cargo build --verbose | |
| - run: cargo test --verbose | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| suffix: linux-x86_64 | |
| target: x86_64-unknown-linux-gnu | |
| ext: so | |
| - os: macos-14 | |
| suffix: macos-arm64 | |
| target: aarch64-apple-darwin | |
| ext: dylib | |
| - os: macos-14 | |
| suffix: ios-arm64 | |
| target: aarch64-apple-ios | |
| ext: a | |
| - os: ubuntu-latest | |
| suffix: android-arm64 | |
| target: aarch64-linux-android | |
| ext: so | |
| runs-on: ${{ matrix.os }} | |
| needs: build_and_test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: rustup update stable && rustup default stable | |
| - run: rustup target add ${{ matrix.target }} | |
| - name: Configure NDK tool-chain | |
| if: matrix.target == 'aarch64-linux-android' | |
| shell: bash | |
| run: | | |
| NDK="$(ls -d "$ANDROID_HOME"/ndk/* | sort -V | tail -n1)" | |
| echo "Using NDK at $NDK" | |
| echo "NDK=$NDK" >> "$GITHUB_ENV" | |
| echo "LLVM_BIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin" >> "$GITHUB_ENV" | |
| echo "$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin" >> "$GITHUB_PATH" | |
| echo "CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang" >> "$GITHUB_ENV" | |
| - name: Extract version from tag | |
| id: extract | |
| run: echo "version=${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT" | |
| - run: cargo build --release --target ${{ matrix.target }} | |
| - name: Archive and rename binary | |
| shell: bash | |
| run: | | |
| VERSION=${{ steps.version.outputs.VERSION }} | |
| SUFFIX=${{ matrix.suffix }} | |
| EXT=${{ matrix.ext }} | |
| mkdir -p dist | |
| SRC="target/${{ matrix.target }}/release/libscal3.${EXT}" | |
| cp "$SRC" "dist/libscal3-${VERSION}-${SUFFIX}.${EXT}" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: bin-${{ matrix.suffix }} | |
| path: dist/* | |
| publish: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: { name: bin-linux-x86_64, path: dist/ } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: bin-macos-arm64, path: dist/ } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: bin-ios-arm64, path: dist/ } | |
| - uses: actions/download-artifact@v4 | |
| with: { name: bin-android-arm64, path: dist/ } | |
| - name: Publish crate | |
| run: cargo publish --locked | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| - name: Create GitHub Release with all binaries | |
| run: | | |
| VERSION=${GITHUB_REF##*/} | |
| gh release create "$VERSION" dist/* \ | |
| --title "Release $VERSION" \ | |
| --verify-tag | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |