Skip to content

Build Worker Native Libs #19

Build Worker Native Libs

Build Worker Native Libs #19

Workflow file for this run

name: Build Worker Native Libs
on:
workflow_dispatch:
inputs:
version:
type: string
required: true
description: Version number (package)
permissions:
packages: write
contents: read
jobs:
build-macos:
name: Build (macOS Universal)
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: chmod +x ./native/nuget/scripts/build_macos.sh && ./native/nuget/scripts/build_macos.sh
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: macos
path: native/src/target/universal-release/*.dylib
build-windows:
name: Build (Windows ${{ matrix.arch }})
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
arch: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- name: Prepare Build Target
run: rustup target add ${{ matrix.arch }}-pc-windows-msvc
- name: Build
run: cargo build --release --target ${{ matrix.arch }}-pc-windows-msvc
working-directory: native/src
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: windows-${{ matrix.arch }}
path: native/src/target/${{ matrix.arch }}-pc-windows-msvc/release/*.dll
build-linux:
name: Build (${{ matrix.vendor }}/Linux ${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [ x86_64, aarch64 ]
vendor: [ gnu, musl ]
env:
RUST_TARGET: ${{ matrix.arch }}-unknown-linux-${{ matrix.vendor }}
steps:
- uses: actions/checkout@v3
# cross-rs is needed if the arch being built isn't the same as the host (linux only)
- name: Install Cross
if: matrix.arch != 'x86_64'
run: cargo install cross --git https://github.com/cross-rs/cross
# also need to ensure the target is installed otherwise musl will fail.
- name: Install Build Target (Non-GNU)
if: matrix.arch == 'x86_64' && matrix.vendor != 'gnu'
run: rustup target install $RUST_TARGET
- name: Build
run: ${{ matrix.arch == 'x86_64' && 'cargo' || 'cross' }} build --release --target $RUST_TARGET
working-directory: native/src
env:
# musl-specific workaround to get files to build - see https://github.com/rust-lang/cargo/issues/7154#issuecomment-561947609
RUSTFLAGS: ${{ matrix.vendor == 'musl' && '-C target-feature=-crt-static' || '' }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: linux-${{ matrix.vendor }}-${{ matrix.arch }}
path: native/src/target/${{ env.RUST_TARGET }}/release/*.so
publish-package:
name: Publish Package
runs-on: ubuntu-latest
needs:
- build-windows
- build-macos
- build-linux
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: macos
path: native/nuget/runtimes/osx/native
- uses: actions/download-artifact@v3
with:
name: windows-x86_64
path: native/nuget/runtimes/win-x64/native
- uses: actions/download-artifact@v3
with:
name: windows-aarch64
path: native/nuget/runtimes/win-arm64/native
- uses: actions/download-artifact@v3
with:
name: linux-musl-x86_64
path: native/nuget/runtimes/linux-musl-x64/native
- uses: actions/download-artifact@v3
with:
name: linux-musl-aarch64
path: native/nuget/runtimes/linux-musl-arm64/native
- uses: actions/download-artifact@v3
with:
name: linux-gnu-x86_64
path: native/nuget/runtimes/linux-x64/native
- uses: actions/download-artifact@v3
with:
name: linux-gnu-aarch64
path: native/nuget/runtimes/linux-arm64/native
- name: Build Package
run: dotnet pack -c Release -p:Version=${{ github.event.inputs.version }} -o ./packages native/nuget
- name: Publish Package
run: dotnet nuget push -s https://nuget.pkg.github.com/dragonfruitnetwork/index.json -k ${{ github.token }} ./packages/*.nupkg