Skip to content

Commit

Permalink
Build on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
YtvwlD committed May 18, 2024
1 parent 2e279fc commit a1a3c0c
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,49 @@ jobs:
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/debug && lipo -create -output target/apple-darwin/debug/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
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ jobs:
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-${{ vars.GITHUB_RUN_ID }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust for i686
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -76,3 +85,48 @@ jobs:
towbootctl-*-x86_64-linux
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-macos:
runs-on: macos-latest
needs: release
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-${{ vars.GITHUB_RUN_ID }}-${{ 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 --release
- name: Build towbootctl for aarch64-apple
uses: actions-rs/cargo@v1
with:
command: build
args: --package towbootctl --target aarch64-apple-darwin --features=binary --release
- name: Build universal binary for macOS
run: mkdir -p target/apple-darwin/release && lipo -create -output target/apple-darwin/release/towbootctl target/x86_64-apple-darwin/release/towbootctl target/aarch64-apple-darwin/release/towbootctl
- name: Upload macOS binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/apple-darwin/release/towbootctl
asset_name: towbootctl-$(git describe --always --tags)-macos
tag: ${{ github.ref }}

0 comments on commit a1a3c0c

Please sign in to comment.