Build shared library for Apple Silicon #162
Workflow file for this run
This file contains 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: CI | |
on: | |
push: | |
branches: [ master ] | |
tags: | |
- '*' | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
name: Build JNI lib for ${{ matrix.build }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- build: x86_64-linux | |
os: ubuntu-latest | |
- build: x86_64-macos | |
os: macos-latest | |
- build: aarch64-macos | |
os: macos-latest | |
target: aarch64-apple-darwin | |
- build: x86_64-windows | |
os: windows-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 1.8 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly-2022-12-11 | |
override: true | |
components: rustfmt | |
# Binary compatibility settings from bytecodealliance/wasmtime | |
- name: Binary compatibility settings (macOS) | |
if: ${{ startsWith(matrix.os, 'macos') }} | |
run: echo 'MACOSX_DEPLOYMENT_TARGET=10.9' >> $GITHUB_ENV | |
- name: Binary compatibility settings (Windows) | |
if: ${{ startsWith(matrix.os, 'windows') }} | |
run: echo 'RUSTFLAGS=-Ctarget-feature=+crt-static' >> $GITHUB_ENV | |
- name: Set build target for cross-compiling | |
if: matrix.target != '' | |
run: | | |
echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV | |
echo JNILIB_RUST_TARGET=${{ matrix.target }} >> $GITHUB_ENV | |
echo GRADLE_ARGS="${GRADLE_ARGS} -x test">> $GITHUB_ENV | |
rustup target add ${{ matrix.target }} | |
# Run gradle in a docker container to build the JNI lib on Linux for old glibc compatibility | |
- name: Build with Gradle (Linux) | |
if: ${{ startsWith(matrix.os, 'ubuntu') }} | |
run: | | |
docker build -t build-image ./ci/docker/x86_64-linux | |
docker run --rm --volume $PWD:/build --workdir /build build-image ./gradlew build copyJniLib -x javadoc | |
# Otherwise, run gradle normally to build the JNI lib | |
- name: Build with Gradle | |
if: ${{ !startsWith(matrix.os, 'ubuntu') }} | |
run: ./gradlew build copyJniLib ${GRADLE_ARGS} | |
- name: List shared library files | |
run: | |
ls build/jni-libs | |
- name: Save JNI lib output | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v2 | |
with: | |
name: jni-libs | |
path: build/jni-libs/* | |
publish: | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 1.8 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 1.8 | |
- name: Restore JNI libs | |
uses: actions/download-artifact@v2 | |
with: | |
name: jni-libs | |
path: build/jni-libs | |
- name: Build universal jar | |
run: ./gradlew universalJar -x buildJniLib -x copyJniLib | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ github.ref }} | |
- id: get-tag-version | |
run: | | |
version=$(echo ${{github.ref}} | cut -f3 -d/ | sed 's/^v//') | |
echo "::set-output name=version::$version" | |
- name: Upload release asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: build/libs/wasmtime-java-${{ steps.get-tag-version.outputs.version }}-universal.jar | |
asset_name: wasmtime-java-${{ steps.get-tag-version.outputs.version }}-universal.jar | |
asset_content_type: application/octet-stream |