Build Native Libraries #6
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: Build Native Libraries | |
on: | |
workflow_dispatch: | |
inputs: | |
build-config: | |
required: true | |
default: 'release' | |
type: choice | |
options: | |
- debug | |
- release | |
build-only-linux: | |
required: true | |
default: false | |
type: boolean | |
update-unity-native: | |
required: true | |
default: false | |
type: boolean | |
workflow_call: | |
inputs: | |
build-config: | |
required: true | |
type: string | |
build-only-linux: | |
required: true | |
type: boolean | |
update-unity-native: | |
required: true | |
type: boolean | |
env: | |
_RUST_BUILD_CONFIG: ${{ inputs.build-config == 'debug' && 'debug' || 'release' }} | |
_DOTNET_BUILD_CONFIG: ${{ inputs.build-config == 'debug' && 'Debug' || 'Release' }} | |
jobs: | |
build-win-x64: | |
name: Build Native library (win-x64) | |
if: ${{ !inputs.build-only-linux }} | |
runs-on: windows-2022 | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: native | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
- run: cargo build --target x86_64-pc-windows-msvc --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }} | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: win-x64 | |
path: native/target/x86_64-pc-windows-msvc/${{ env._RUST_BUILD_CONFIG }}/yaha_native.dll | |
retention-days: 1 | |
- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test | |
build-win-arm64: | |
name: Build Native library (win-arm64) | |
if: ${{ !inputs.build-only-linux }} | |
runs-on: windows-2022 | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: native | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
- run: rustup target add aarch64-pc-windows-msvc | |
- run: | | |
$env:Path += ";C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\bin" | |
cargo build --target aarch64-pc-windows-msvc --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }} | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: win-arm64 | |
path: native/target/aarch64-pc-windows-msvc/${{ env._RUST_BUILD_CONFIG }}/yaha_native.dll | |
retention-days: 1 | |
#- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test | |
build-win-arm64-uwp: | |
name: Build Native library (win-arm64-uwp) | |
if: ${{ !inputs.build-only-linux }} | |
runs-on: windows-2022 | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: native | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
- run: rustup toolchain install nightly-2024-07-10-x86_64-pc-windows-msvc | |
- run: rustup component add rust-src --toolchain nightly-2024-07-10-x86_64-pc-windows-msvc | |
- run: rustup default nightly-2024-07-10 | |
- run: | | |
$env:Path += ";C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\bin" | |
cargo -Z build-std build --target aarch64-uwp-windows-msvc --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }} | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: win-arm64-uwp | |
path: native/target/aarch64-uwp-windows-msvc/${{ env._RUST_BUILD_CONFIG }}/yaha_native.dll | |
retention-days: 1 | |
#- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test | |
build-linux-x64: | |
name: Build Native library (linux-x64) | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: native | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
- run: cargo build --target x86_64-unknown-linux-gnu --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }} | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: linux-x64 | |
path: native/target/x86_64-unknown-linux-gnu/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.so | |
retention-days: 1 | |
- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test | |
build-osx-x64: | |
name: Build Native library (osx-x64) | |
if: ${{ !inputs.build-only-linux }} | |
runs-on: macos-13 # Intel | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: native | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
- run: rustup target add x86_64-apple-darwin | |
- run: cargo build --target x86_64-apple-darwin --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }} | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: osx-x64 | |
path: native/target/x86_64-apple-darwin/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.dylib | |
retention-days: 1 | |
- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test | |
build-osx-arm64: | |
name: Build Native library (osx-arm64) | |
if: ${{ !inputs.build-only-linux }} | |
runs-on: macos-latest # Apple Silicon | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: native | |
steps: | |
- uses: actions/checkout@v4 | |
- run: rustup target add aarch64-apple-darwin | |
- run: cargo build --target aarch64-apple-darwin --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }} | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: osx-arm64 | |
path: native/target/aarch64-apple-darwin/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.dylib | |
retention-days: 1 | |
- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ../test/YetAnotherHttpHandler.Test | |
build-ios-x64: | |
name: Build Native library (ios-x64) | |
if: ${{ !inputs.build-only-linux }} | |
runs-on: macos-latest | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: native | |
steps: | |
- uses: actions/checkout@v4 | |
- run: rustup target add x86_64-apple-ios | |
- run: cargo build --target x86_64-apple-ios --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }} | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: ios-x64 | |
path: native/target/x86_64-apple-ios/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.a | |
retention-days: 1 | |
build-ios-arm64: | |
name: Build Native library (ios-arm64) | |
if: ${{ !inputs.build-only-linux }} | |
runs-on: macos-latest | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: native | |
steps: | |
- uses: actions/checkout@v4 | |
- run: rustup target add aarch64-apple-ios | |
- run: cargo build --target aarch64-apple-ios --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }} | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: ios-arm64 | |
path: native/target/aarch64-apple-ios/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.a | |
retention-days: 1 | |
build-android-arm: | |
name: Build Native library (android-arm) | |
if: ${{ !inputs.build-only-linux }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: native | |
steps: | |
- uses: actions/checkout@v4 | |
- run: sudo apt update && sudo apt install gcc-multilib | |
- run: rustup target add armv7-linux-androideabi | |
- run: cargo install cargo-ndk | |
- run: cargo ndk -t armeabi-v7a build --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }} | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: android-arm | |
path: native/target/armv7-linux-androideabi/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.so | |
retention-days: 1 | |
build-android-arm64: | |
name: Build Native library (android-arm64) | |
if: ${{ !inputs.build-only-linux }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: native | |
steps: | |
- uses: actions/checkout@v4 | |
- run: sudo apt update && sudo apt install gcc-multilib | |
- run: rustup target add aarch64-linux-android | |
- run: cargo install cargo-ndk | |
- run: cargo ndk -t arm64-v8a build --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }} | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: android-arm64 | |
path: native/target/aarch64-linux-android/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.so | |
retention-days: 1 | |
build-android-x64: | |
name: Build Native library (android-x64) | |
if: ${{ !inputs.build-only-linux }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: native | |
steps: | |
- uses: actions/checkout@v4 | |
- run: sudo apt update && sudo apt install gcc-multilib | |
- run: rustup target add x86_64-linux-android | |
- run: cargo install cargo-ndk | |
- run: cargo ndk -t x86_64 build --profile ${{ env._RUST_BUILD_CONFIG == 'debug' && 'dev' || env._RUST_BUILD_CONFIG }} | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: android-x64 | |
path: native/target/x86_64-linux-android/${{ env._RUST_BUILD_CONFIG }}/libyaha_native.so | |
retention-days: 1 | |
build-dotnet: | |
name: Build and pack .NET library | |
if: ${{ inputs.build-only-linux && needs.build-linux-x64.result == 'success' || success() }} | |
needs: | |
- build-win-x64 | |
- build-win-arm64 | |
- build-win-arm64-uwp | |
- build-linux-x64 | |
- build-osx-x64 | |
- build-osx-arm64 | |
- build-ios-x64 | |
- build-ios-arm64 | |
- build-android-arm | |
- build-android-arm64 | |
- build-android-x64 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Cysharp/Actions/.github/actions/download-artifact@main | |
with: | |
path: native/artifacts | |
- run: ls -lFaR native/artifacts | |
- run: dotnet pack -c ${{ env._DOTNET_BUILD_CONFIG }} ./YetAnotherHttpHandler.sln --include-symbols --include-source -o ./publish | |
#- run: dotnet test -c ${{ env._DOTNET_BUILD_CONFIG }} ./test/YetAnotherHttpHandler.Packaging.Test | |
- uses: Cysharp/Actions/.github/actions/upload-artifact@main | |
with: | |
name: nuget-packages | |
path: ./publish/ | |
retention-days: 7 | |
update-unity-native: | |
name: Update pre-built libraries for Unity | |
if: ${{ inputs.update-unity-native && (inputs.build-only-linux && needs.build-dotnet.result == 'success' || success()) }} | |
needs: [ build-dotnet ] | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Cysharp/Actions/.github/actions/download-artifact@main | |
with: | |
name: nuget-packages | |
path: ./publish/ | |
- run: unzip -o ./publish/YetAnotherHttpHandler.*[0-9].nupkg 'runtimes/*' -d src/YetAnotherHttpHandler/Plugins/Cysharp.Net.Http.YetAnotherHttpHandler.Native/ || true | |
- run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -m "Update pre-built native libraries" src/YetAnotherHttpHandler/Plugins/**/* | |
git push origin ${{ github.ref_name }} |