Skip to content

Commit

Permalink
Create universal binary as part of the macos subjobs
Browse files Browse the repository at this point in the history
And fix issues
  • Loading branch information
lionel- committed Aug 30, 2024
1 parent 7f2269a commit 836b293
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 33 deletions.
73 changes: 70 additions & 3 deletions .github/workflows/release-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ on:
workflow_call:
inputs:
version:
required: false
required: true
description: "The Ark version"
default: ${{ github.sha }}
type: string
workflow_dispatch:
inputs:
version:
required: false
description: "The Ark version"
default: dev
type: string

jobs:
# Build ARK for macOS. Both arm64 (Apple Silicon) and x64 (Intel) hosts.
Expand All @@ -23,7 +28,7 @@ jobs:
strategy:
matrix:
arch: [arm64, x64]
flavor: [debug, release]
flavor: [release, debug]
include:
- arch: arm64
arch_terminal: arm64
Expand Down Expand Up @@ -92,3 +97,65 @@ jobs:
with:
name: ark-${{ matrix.flavor }}-darwin-${{ matrix.arch }}-archive
path: ark-${{ inputs.version }}-${{ matrix.flavor }}-darwin-${{ matrix.arch }}.zip


build_universal:
name: Build macOS universal binary
runs-on: macos-latest
timeout-minutes: 40
needs: build_macos

env:
DEBUG_FLAG: ${{ matrix.flavor == 'debug' && '-debug' || '' }}

strategy:
matrix:
flavor: [release, debug]

steps:
- name: Checkout sources to get copies of LICENSE and NOTICE
uses: actions/checkout@v4
with:
sparse-checkout: |
LICENSE
crates/ark/NOTICE
- name: Download macOS arm64 kernel (${{ matrix.flavor }})
uses: actions/download-artifact@v4
with:
name: ark-${{ matrix.flavor }}-darwin-arm64-archive

- name: Download macOS x64 kernel (${{ matrix.flavor}})
uses: actions/download-artifact@v4
with:
name: ark-${{ matrix.flavor }}-darwin-x64-archive

# Combine macOS binaries to a single binary with lipo
- name: Create macOS universal binary
run: |
# Decompress x64 builds
rm -rf x64 && mkdir x64
pushd x64
unzip ../ark-${{ inputs.version }}-${{ matrix.flavor }}-darwin-x64.zip
popd
# Decompress arm64 build
rm -rf arm64 && mkdir arm64
pushd arm64
unzip ../ark-${{ inputs.version }}-${{ matrix.flavor }}-darwin-arm64.zip
popd
# Create a universal binary
lipo -create x64/ark arm64/ark -output ark
# Compress and bundle licenses
ARCHIVE="$GITHUB_WORKSPACE/ark-${{ inputs.version }}${{ env.DEBUG_FLAG }}-darwin-universal.zip"
[ -e LICENSE ] || cp "$GITHUB_WORKSPACE/LICENSE" LICENSE
[ -e NOTICE ] || cp "$GITHUB_WORKSPACE/crates/ark/NOTICE" NOTICE
zip -Xry $ARCHIVE ark LICENSE NOTICE
- name: Upload client archive
uses: actions/upload-artifact@v4
with:
name: ark-${{ matrix.flavor }}-darwin-universal-archive
path: ark-${{ inputs.version }}${{ env.DEBUG_FLAG }}-darwin-universal.zip
32 changes: 2 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,10 @@ jobs:

steps:
# Download all binaries
- name: Download macOS arm64 kernel (${{ matrix.flavor }})
- name: Download macOS universal kernel (${{ matrix.flavor}})
uses: actions/download-artifact@v4
with:
name: ark-${{ matrix.flavor }}-darwin-arm64-archive

- name: Download macOS x64 kernel (${{ matrix.flavor}})
uses: actions/download-artifact@v4
with:
name: ark-${{ matrix.flavor }}-darwin-x64-archive
name: ark-${{ matrix.flavor }}-darwin-universal-archive

- name: Download Windows x64 kernel (${{ matrix.flavor}})
uses: actions/download-artifact@v4
Expand All @@ -134,29 +129,6 @@ jobs:
with:
name: ark-${{ matrix.flavor }}-linux-x64-archive


# Combine macOS binaries to a single binary with lipo
- name: Create macOS universal binary
run: |
# Decompress x64 builds
rm -rf x64 && mkdir x64 && pushd x64
unzip ../ark-${{ needs.get_version.outputs.ARK_VERSION }}-${{ matrix.flavor }}-darwin-x64.zip
popd
# Decompress arm64 build
rm -rf arm64 && mkdir arm64 && pushd arm64
unzip ../ark-${{ needs.get_version.outputs.ARK_VERSION }}-${{ matrix.flavor }}-darwin-arm64.zip
popd
# Create a universal binary
lipo -create x64/ark arm64/ark -output ark
# Compress and bundle licenses
ARCHIVE="$GITHUB_WORKSPACE/ark-${{ needs.get_version.outputs.ARK_VERSION }}${{ env.DEBUG_FLAG }}-darwin-universal.zip"
[ -e LICENSE ] || cp "$GITHUB_WORKSPACE/LICENSE" LICENSE
[ -e NOTICE ] || cp "$GITHUB_WORKSPACE/crates/ark/NOTICE" NOTICE
zip -Xry $ARCHIVE ark LICENSE NOTICE
- name: Upload macOS release artifact (universal)
uses: actions/upload-release-asset@v1
env:
Expand Down

0 comments on commit 836b293

Please sign in to comment.