Skip to content

Build 64-bit universal binaries on macos #159

Build 64-bit universal binaries on macos

Build 64-bit universal binaries on macos #159

Workflow file for this run

name: build
on:
push:
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-latest
# make this workflow run on self-hosted runner
# runs-on: self-hosted
env:
CARGO_TERM_COLOR: always
steps:
# Install static linking (musl) deps
- name: Install static link deps
run: sudo apt update && sudo apt install -y pkg-config musl-tools libssl-dev
# Setup Rust, use the x86_64-apple-darwin target but the rest can be customized.
- name: Setup Rust
uses: ATiltedTree/setup-rust@v1
with:
targets: x86_64-apple-darwin x86_64-unknown-linux-musl aarch64-apple-darwin aarch64-unknown-linux-musl
rust-version: stable
# Use the v1 of this action
- name: Setup OSXCROSS
uses: mbround18/setup-osxcross@v1
# This builds executables & sets env variables for rust to consume.
with:
osx-version: "12.3"
- name: Clone your Code
uses: actions/checkout@v3
- name: Rust Cache
uses: Swatinem/rust-cache@v2.2.0
- name: Build for x86 Linux
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Build for x86 macOS
run: cargo build --release --target x86_64-apple-darwin
- name: Build for ARM Linux
run: cargo build --release --target aarch64-unknown-linux-musl
- name: Build for ARM macOS
run: cargo build --release --target aarch64-apple-darwin
- name: Build for Universal macOS
run: lipo -create -output target/deepctl-macos-universal target/x86_64-apple-darwin/release/deepctl target/aarch64-apple-darwin/release/deepctl
- uses: actions/upload-artifact@v3
with:
name: deepctl-linux-x86_64
path: target/x86_64-unknown-linux-musl/release/deepctl
- uses: actions/upload-artifact@v3
with:
name: deepctl-macos-universal
path: target/deepctl-macos-universal
- uses: actions/upload-artifact@v3
with:
name: deepctl-linux-arm64
path: target/aarch64-unknown-linux-musl/release/deepctl
release:
name: Release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
# make this workflow run on self-hosted runner
# runs-on: self-hosted
env:
CARGO_TERM_COLOR: always
steps:
# Install static linking (musl) deps
- name: Install static link deps
run: sudo apt update && sudo apt install -y pkg-config musl-tools libssl-dev
# Setup Rust, use the x86_64-apple-darwin target but the rest can be customized.
- name: Setup Rust
uses: ATiltedTree/setup-rust@v1
with:
targets: x86_64-apple-darwin x86_64-unknown-linux-musl
rust-version: stable
# Use the v1 of this action
- name: Setup OSXCROSS
uses: mbround18/setup-osxcross@v1
# This builds executables & sets env variables for rust to consume.
with:
osx-version: "12.3"
# Checkout your code
- name: Clone your Code
uses: actions/checkout@v3
- name: Rust Cache
uses: Swatinem/rust-cache@v2.2.0
- name: Install apple-codesign
run: cargo install apple-codesign
# Build your code for apple-darwin based release
- name: Build for x86 macOS
run: cargo build --release --target x86_64-apple-darwin
- name: Build for ARM macOS
run: cargo build --release --target aarch64-apple-darwin
- name: Build for Universal macOS
run: lipo -create -output target/deepctl-macos-universal target/x86_64-apple-darwin/release/deepctl target/aarch64-apple-darwin/release/deepctl
# Build your code for apple-darwin based release
- name: Build for x86 Linux
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Build for ARM Linux
run: cargo build --release --target aarch64-unknown-linux-musl
- name: Get secrets
env:
CERT_PASSWORD: ${{ secrets.DEEP_INFRA_APPLE_CERT_PASSWORD }}
APP_STORE_CONNECT: ${{ secrets.DEEP_INFRA_APP_STORE_CONNECT }}
SIGNING_CERTIFICATE: ${{ secrets.DEEP_INFRA_SIGNING_CERTIFICATE }}
run: |
echo $CERT_PASSWORD > cert_password
echo $APP_STORE_CONNECT > app_store_connect.json
echo $SIGNING_CERTIFICATE | base64 -di > signing_certificate.p12
- name: Sign the MacOS binary
run: |
ls -la target/*/release/deepctl target/deepctl-macos-universal
echo "Signing the MacOS binary"
rcodesign sign \
--p12-file signing_certificate.p12 --p12-password-file cert_password \
--code-signature-flags runtime \
target/deepctl-macos-universal
echo "Zipping"
zip target/deepctl-macos-universal.zip target/deepctl-macos-universal
echo "Notarizing"
rcodesign notary-submit \
--api-key-path app_store_connect.json \
--wait \
target/deepctl-macos-universal.zip
echo "Done notarizing"
- name: Cleanup secrets
if: always()
run: |
rm cert_password
rm app_store_connect.json
rm signing_certificate.p12
- name: Prepare Release
run: |
mkdir release
cp target/deepctl-macos-universal release/deepctl-macos-universal
cp target/x86_64-unknown-linux-musl/release/deepctl release/deepctl-linux-x86_64
cp target/aarch64-unknown-linux-musl/release/deepctl release/deepctl-linux-arm64
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
release/deepctl-macos
release/deepctl-linux
install.sh