Skip to content

fix: implemented zig for cross-compilation to aarch linux build #33

fix: implemented zig for cross-compilation to aarch linux build

fix: implemented zig for cross-compilation to aarch linux build #33

Workflow file for this run

name: 'publish'
on:
push:
branches: [ '**' ] # To run on any branch
pull_request:
branches: [ '**' ]
workflow_dispatch:
jobs:
publish-tauri:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: 'macos-latest' # for Arm based macs (M1 and above).
args: '--target aarch64-apple-darwin'
- platform: 'macos-latest' # for Intel based macs.
args: '--target x86_64-apple-darwin'
- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04.
args: '--target x86_64-unknown-linux-gnu'
- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04.
args: '--target aarch64-unknown-linux-gnu'
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || matrix.args == '--target aarch64-unknown-linux-gnu' && 'aarch64-unknown-linux-gnu' || '' }}
- name: Install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
- name: Setup cross-compilation for aarch64
if: matrix.args == '--target aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
sudo apt-get install -y libssl-dev pkg-config
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV
- name: Install and configure Zig for aarch64 cross-compilation
if: matrix.args == '--target aarch64-unknown-linux-gnu'
run: |
wget https://ziglang.org/download/0.11.0/zig-linux-x86_64-0.11.0.tar.xz
tar -xf zig-linux-x86_64-0.11.0.tar.xz
echo "ZIG_PATH=$PWD/zig-linux-x86_64-0.11.0/zig" >> $GITHUB_ENV
echo "$PWD/zig-linux-x86_64-0.11.0" >> $GITHUB_PATH
zig-linux-x86_64-0.11.0/zig version
echo "CARGO_ZIGBUILD_ZIG=$PWD/zig-linux-x86_64-0.11.0/zig" >> $GITHUB_ENV
cargo install cargo-zigbuild
- name: Install frontend dependencies
run: pnpm install
- name: Build Tauri app for AArch64
if: matrix.args == '--target aarch64-unknown-linux-gnu'
env:
RUSTFLAGS: "-C target-feature=+crt-static"
run: |
cargo zigbuild --release --target aarch64-unknown-linux-gnu
- name: Build Tauri app for other targets
if: matrix.args != '--target aarch64-unknown-linux-gnu'
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: app-v__VERSION__
releaseName: 'App v__VERSION__'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: true
prerelease: false
args: ${{ matrix.args }}