Files
leaf/.github/workflows/ci.yml
2022-04-20 23:02:35 +08:00

170 lines
4.9 KiB
YAML

name: ci
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v2
with:
submodules: true
- name: install rust toolchain
uses: hecrj/setup-rust-action@v1
with:
rust-version: nightly
- name: test leaf
run: cargo test -p leaf
build-bin-cross:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- mips-unknown-linux-musl
# - mipsel-unknown-linux-musl
- x86_64-unknown-linux-musl
# - i686-unknown-linux-musl
- aarch64-unknown-linux-musl
# - arm-unknown-linux-musleabi
# - armv7-unknown-linux-musleabihf
- x86_64-pc-windows-gnu
steps:
- name: checkout
uses: actions/checkout@v2
with:
submodules: true
- name: install rust toolchain
uses: hecrj/setup-rust-action@v1
with:
rust-version: nightly
- name: install deps
run: |
sudo apt update && sudo apt install llvm-dev libclang-dev clang libssl-dev pkg-config protobuf-compiler make -y
- name: install cross
run: |
cargo install cross
- name: build
run: |
export CFG_COMMIT_HASH=`git log --pretty=format:'%h' -n 1`
export CFG_COMMIT_DATE=`git log --format="%ci" -n 1`
./misc/build_cross.sh ${{ matrix.target }}
- name: rename and compress artifacts
if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }}
run: |
mv target/${{ matrix.target }}/release/leaf.exe leaf-${{ matrix.target }}.exe
- name: rename and compress artifacts
if: ${{ matrix.target != 'x86_64-pc-windows-gnu' }}
run: |
mv target/${{ matrix.target }}/release/leaf leaf-${{ matrix.target }}
- name: upload assets
if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }}
uses: actions/upload-artifact@v2
with:
name: leaf-${{ matrix.target }}.exe
path: leaf-${{ matrix.target }}.exe
- name: upload assets
if: ${{ matrix.target != 'x86_64-pc-windows-gnu' }}
uses: actions/upload-artifact@v2
with:
name: leaf-${{ matrix.target }}
path: leaf-${{ matrix.target }}
build-bin-local:
strategy:
matrix:
os: [macos-latest]
include:
- os: macos-latest
target: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v2
with:
submodules: true
- name: show last commit
run: |
git show --summary
- name: install rust toolchain
uses: hecrj/setup-rust-action@v1
with:
rust-version: nightly
- name: install llvm
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew update && brew install llvm protobuf
- name: build
run: |
export CFG_COMMIT_HASH=`git log --pretty=format:'%h' -n 1`
export CFG_COMMIT_DATE=`git log --format="%ci" -n 1`
cargo build --release --target ${{ matrix.target }} -p leaf-bin
- name: rename and compress artifacts
run: |
mv target/${{ matrix.target }}/release/leaf leaf-${{ matrix.target }}
- name: upload assets
uses: actions/upload-artifact@v2
with:
name: leaf-${{ matrix.target }}
path: leaf-${{ matrix.target }}
# build-lib-ios:
# runs-on: macos-latest
# steps:
# - name: checkout
# uses: actions/checkout@v2
# with:
# submodules: true
#
# - name: install rust
# uses: hecrj/setup-rust-action@v1
# with:
# rust-version: nightly
#
# - name: install toolchain
# run: |
# rustup target add aarch64-apple-ios
# cargo install cargo-lipo
# cargo install cbindgen
# brew update && brew install llvm unzip protobuf
#
# - name: build
# run: |
# make ios
#
# - name: zip artifacts
# run: |
# mv target/universal/release/libleaf.a .
# mv target/universal/release/leaf.h .
# zip libleaf-ios.zip leaf.h libleaf.a
#
# - name: upload assets
# uses: actions/upload-artifact@v2
# with:
# name: libleaf-ios.zip
# path: libleaf-ios.zip