Skip to content

Build binaries

Build binaries #13

# Authors:
#
# Sam Gold <https://github.com/goldsam>
# Sebastian Stehle <https://github.com/SebastianStehle>
# Lucas Viana <https://github.com/LSViana>
name: Build binaries
on:
workflow_dispatch:
env:
YRS_REPO: https://github.com/LSViana/y-crdt
YRS_BRANCH: main
CARGO_TERM_COLOR: always
jobs:
# Based on https://www.rohanjain.in/cargo-cross/
build-native-binaries:
runs-on: ${{matrix.os}}
strategy:
matrix:
include:
# Windows
- build: win-x64
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc
linker: mingw-w64
cross: false
# Linux
- build: linux-x64
os: ubuntu-20.04
rust: stable
target: x86_64-unknown-linux-gnu
cross: false
- build: linux-x64-musl
os: ubuntu-20.04
rust: stable
target: x86_64-unknown-linux-musl
cross: false
- build: linux-armv7
os: ubuntu-20.04
rust: stable
target: armv7-unknown-linux-gnueabihf
linker: gcc-arm-linux-gnueabihf
cross: true
- build: linux-armv7-musl
os: ubuntu-20.04
rust: stable
target: armv7-unknown-linux-musleabihf
linker: gcc-arm-linux-gnueabihf
cross: true
- build: linux-arm64
os: ubuntu-20.04
rust: stable
target: aarch64-unknown-linux-gnu
linker: gcc-aarch64-linux-gnu
cross: true
- build: linux-arm64-musl
os: ubuntu-20.04
rust: stable
target: aarch64-unknown-linux-musl
linker: gcc-aarch64-linux-gnu
cross: true
# macOS
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
cross: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Cross
if: matrix.cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Install musl tools
run: sudo apt install -y musl musl-dev musl-tools
if: endsWith(matrix.build, '-musl')
- name: Install Linker
if: matrix.cross
run: |
sudo apt update
sudo apt install ${{ matrix.linker }}
cat .cargo/config.github >> .cargo/config
- name: Install Rust
run: |
rustup install ${{ matrix.rust }}
rustup target add ${{ matrix.target }}
rustup show
- name: Clone Yrs
run: |
git clone ${YRS_REPO} --branch ${YRS_BRANCH} --single-branch yrs
shell: bash
- name: Patch Build
run: |
cd yrs
git apply ../native/build.patch
shell: bash
- name: Build (Cargo)
if: "!matrix.cross"
run: |
cd yrs
RUSTFLAGS="-C target-feature=-crt-static" cargo build --release --target ${{ matrix.target }}
shell: bash
- name: Build (Cross)
if: matrix.cross
run: |
cd yrs
RUSTFLAGS="-C target-feature=-crt-static" cross build --release --target ${{ matrix.target }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.build }}
path: |
yrs/target/${{ matrix.target }}/release/*yrs.dll
yrs/target/${{ matrix.target }}/release/*yrs.so
yrs/target/${{ matrix.target }}/release/*yrs.dylib