Try building on macOS #163
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache Cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install Rust for i686 | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
override: true | |
target: i686-unknown-uefi | |
- name: Install Rust for x86_64 | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
override: true | |
target: x86_64-unknown-uefi | |
- name: Build for i686 | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --package towboot --target i686-unknown-uefi | |
- name: Upload i686 artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: towboot-debug-i686.efi | |
path: target/i686-unknown-uefi/debug/towboot.efi | |
- name: Build for x86_64 | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --package towboot --target x86_64-unknown-uefi | |
- name: Upload x86_64 artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: towboot-debug-x86_64.efi | |
path: target/x86_64-unknown-uefi/debug/towboot.efi | |
- name: Build towbootctl for x86_64-linux | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --package towbootctl --target x86_64-unknown-linux-gnu --features=binary | |
- name: Upload x86_64-linux artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: towbootctl-debug-x86_64-linux | |
path: target/x86_64-unknown-linux-gnu/debug/towbootctl | |
- name: Install compiler for x86_64-windows | |
run: sudo apt-get update && sudo apt-get install gcc-mingw-w64-x86-64-win32 | |
- name: Install Rust for x86_64-windows | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
target: x86_64-pc-windows-gnu | |
- name: Build towbootctl for x86_64-windows | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --package towbootctl --target x86_64-pc-windows-gnu --features=binary | |
- name: Upload x86_64-windows artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: towbootctl-debug-x86_64-windows.exe | |
path: target/x86_64-pc-windows-gnu/debug/towbootctl.exe | |
- name: Install qemu | |
run: sudo apt-get update && sudo apt-get install -y qemu-system-x86 | |
- name: Enable KVM group perms | |
run: | | |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | |
sudo udevadm control --reload-rules | |
sudo udevadm trigger --name-match=kvm | |
# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/ | |
- name: Run tests | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --package tests | |
build-mac: | |
# We could cross-compile from Linux instead, | |
# but we'd still need the Xcode Command Line Tools. | |
# Downloading them requires logging in with an Apple ID, | |
# which is not possible in the CI. The macOS runners include it. | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache Cargo | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install Rust for x86_64-apple | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
override: true | |
target: x86_64-apple-darwin | |
- name: Install Rust for aarch64-apple | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
override: true | |
target: aarch64-apple-darwin | |
- name: Build towbootctl for x86_64-apple | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --package towbootctl --target x86_64-apple-darwin --features=binary | |
- name: Build towbootctl for aarch64-apple | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --package towbootctl --target aarch64-apple-darwin --features=binary | |
- name: Build universal binary for macos | |
run: mkdir -p target/apple-darwin && lipo -create -output target/apple-darwin/towbootctl target/x86_64-apple-darwin/debug/towbootctl target/aarch64-apple-darwin/debug/towbootctl | |
- name: Upload apple artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: towbootctl-debug-macos | |
path: target/apple-darwin/debug/towbootctl |