Skip to content

Commit

Permalink
ci: improve build process to use a matrix and add binary for windows …
Browse files Browse the repository at this point in the history
…aarch64
  • Loading branch information
vemonet committed Mar 30, 2024
1 parent 2a7fae5 commit ab8f3ba
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 98 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
142 changes: 44 additions & 98 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,123 +17,69 @@ concurrency:
# cf. https://github.com/oxigraph/oxigraph/blob/main/.github/workflows/artifacts.yml
jobs:

binary_linux:
name: 🐧 Build binaries for Linux
runs-on: ubuntu-latest
# Build binary for more targets?
# '--target', 'i686-pc-windows-msvc',
# '--target', 'armv7-linux-androideabi',
# '--target', 'thumbv7neon-linux-androideabi',
# '--target', 'aarch64-linux-android',
# '--target', 'i686-linux-android',
# '--target', 'x86_64-linux-android',

build_binaries:
name: Build binaries for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: aarch64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update && rustup target add aarch64-unknown-linux-gnu

- run: |
sudo apt update && sudo apt install -y g++-aarch64-linux-gnu
echo -e "\n\n[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml
- uses: Swatinem/rust-cache@v2

- run: cargo build --release
working-directory: ./cli

- run: cargo build --release --target aarch64-unknown-linux-gnu
working-directory: ./cli
env:
BINDGEN_EXTRA_CLANG_ARGS: --sysroot /usr/aarch64-linux-gnu

- uses: actions/upload-artifact@v4
with:
name: nanopub_x86_64_linux_gnu
path: target/release/nanopub-cli
- uses: actions/upload-artifact@v4
with:
name: nanopub_aarch64_linux_gnu
path: target/aarch64-unknown-linux-gnu/release/nanopub-cli
- name: Add target
run: rustup update && rustup target add ${{ matrix.target }}

- if: startsWith(github.ref, 'refs/tags/')
run: |
mv target/release/nanopub-cli nanopub_x86_64_linux_gnu
mv target/aarch64-unknown-linux-gnu/release/nanopub-cli nanopub_aarch64_linux_gnu
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
nanopub_x86_64_linux_gnu
nanopub_aarch64_linux_gnu
# nanopub_${{ github.event.release.tag_name }}_x86_64_linux_gnu
# tag_name: ${{ github.event.release.tag_name }}


binary_mac:
name: 🍎 Build binaries for MacOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update && rustup target add aarch64-apple-darwin

- run: |
sudo apt update && sudo apt install -y g++-aarch64-linux-gnu
echo -e "\n\n[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml
- name: Install aarch64 dependencies
if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'aarch64-apple-darwin'
run: sudo apt update && sudo apt install -y g++-aarch64-linux-gnu
# echo -e "\n\n[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml

- uses: Swatinem/rust-cache@v2

- run: cargo build --release
working-directory: ./cli

- run: cargo build --release --target aarch64-apple-darwin
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
working-directory: ./cli
# env:
# BINDGEN_EXTRA_CLANG_ARGS: --sysroot /usr/aarch64-linux-gnu

- uses: actions/upload-artifact@v4
with:
name: nanopub_x86_64_apple
path: target/release/nanopub-cli
- uses: actions/upload-artifact@v4
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nanopub_aarch64_apple
path: target/aarch64-apple-darwin/release/nanopub-cli
name: nanopub_${{ matrix.target }}
path: target/${{ matrix.target }}/release/nanopub-cli${{ matrix.os == 'Windows' && '.exe' || '' }}

- if: startsWith(github.ref, 'refs/tags/')
name: Prepare for release
run: |
mv target/release/nanopub-cli nanopub_x86_64_apple
mv target/aarch64-apple-darwin/release/nanopub-cli nanopub_aarch64_apple
mv target/${{ matrix.target }}/release/nanopub-cli${{ matrix.os == 'Windows' && '.exe' || '' }} nanopub_${{ matrix.target }}${{ matrix.os == 'Windows' && '.exe' || '' }}
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
nanopub_x86_64_apple
nanopub_aarch64_apple
nanopub_${{ matrix.target }}${{ matrix.os == 'Windows' && '.exe' || '' }}
binary_windows:
name: 🪟 Build binaries for Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2

- run: cargo build --release
working-directory: ./cli

- uses: actions/upload-artifact@v4
with:
name: nanopub_x86_64_windows_msvc
path: target/release/nanopub-cli.exe

- if: startsWith(github.ref, 'refs/tags/')
run: |
mv target/release/nanopub-cli.exe nanopub_x86_64_windows_msvc.exe
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
nanopub_x86_64_windows_msvc.exe
# Inspired by https://github.com/pydantic/pydantic-core/blob/main/.github/workflows/ci.yml
build_wheels:
Expand Down

0 comments on commit ab8f3ba

Please sign in to comment.