Skip to content

Commit 585eee0

Browse files
committed
fix: build universal macOS release assets
1 parent b775a88 commit 585eee0

4 files changed

Lines changed: 53 additions & 9 deletions

File tree

.github/workflows/release-assets.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ jobs:
9595
9696
- name: Install Rust toolchain
9797
uses: dtolnay/rust-toolchain@stable
98+
with:
99+
targets: |
100+
aarch64-apple-darwin
101+
x86_64-apple-darwin
98102
99103
- name: Cache Rust artifacts
100104
uses: Swatinem/rust-cache@v2
@@ -113,12 +117,15 @@ jobs:
113117
if: steps.release-gate.outputs.signed_release == 'true'
114118
run: bash scripts/install_macos_codesign_certificate.sh
115119

120+
- name: Build universal macOS dependencies
121+
run: TASKERS_MACOS_DEP_MODE=universal bash scripts/macos-build-preview-deps.sh
122+
116123
- name: Generate Xcode project
117-
run: bash scripts/generate_macos_project.sh
124+
run: TASKERS_MACOS_DEP_MODE=universal bash scripts/generate_macos_project.sh
118125

119126
- name: Build universal Taskers.app
120127
run: |
121-
xcodebuild build \
128+
TASKERS_SKIP_MACOS_PREBUILD_DEPS=1 xcodebuild build \
122129
-project macos/Taskers.xcodeproj \
123130
-scheme TaskersMac \
124131
-configuration Release \

macos/project.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ targets:
3838
preBuildScripts:
3939
- name: Build macOS Preview Dependencies
4040
script: |
41-
"${SRCROOT}/../scripts/macos-build-preview-deps.sh"
41+
if [ "${TASKERS_SKIP_MACOS_PREBUILD_DEPS:-0}" != "1" ]; then
42+
"${SRCROOT}/../scripts/macos-build-preview-deps.sh"
43+
fi
4244
basedOnDependencyAnalysis: false
4345
postBuildScripts:
4446
- name: Stage App Bundle Support

scripts/generate_macos_project.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ set -euo pipefail
33

44
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
55
cd "${ROOT_DIR}"
6+
BUILD_MODE="${TASKERS_MACOS_DEP_MODE:-native}"
7+
MODE_STAMP="build/macos/.deps-mode"
68

79
if [[ ! -d build/macos/GhosttyKit.xcframework ]] \
810
|| [[ ! -f build/macos/libtaskers_macos_ffi.a ]] \
9-
|| [[ ! -x build/macos/bin/taskersctl ]]; then
11+
|| [[ ! -x build/macos/bin/taskersctl ]] \
12+
|| [[ ! -f "${MODE_STAMP}" ]] \
13+
|| [[ "$(<"${MODE_STAMP}")" != "${BUILD_MODE}" ]]; then
1014
bash scripts/macos-build-preview-deps.sh
1115
fi
1216

scripts/macos-build-preview-deps.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,45 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
55
BUILD_DIR="${ROOT_DIR}/build/macos"
66
GHOSTTY_DIR="${ROOT_DIR}/vendor/ghostty"
77
GHOSTTY_VERSION="$(sed -n 's/^.*\.version = "\([^"]*\)".*$/\1/p' "${GHOSTTY_DIR}/build.zig.zon" | head -n1)"
8+
BUILD_MODE="${TASKERS_MACOS_DEP_MODE:-native}"
9+
MODE_STAMP="${BUILD_DIR}/.deps-mode"
10+
11+
case "${BUILD_MODE}" in
12+
native|universal)
13+
;;
14+
*)
15+
echo "unsupported TASKERS_MACOS_DEP_MODE=${BUILD_MODE}; expected native or universal" >&2
16+
exit 1
17+
;;
18+
esac
819

920
mkdir -p "${BUILD_DIR}/bin" "${BUILD_DIR}/resources"
1021

1122
pushd "${ROOT_DIR}" >/dev/null
12-
cargo build --release -p taskers-macos-ffi
13-
cargo build --release -p taskers-cli --bin taskersctl
23+
if [[ "${BUILD_MODE}" == "universal" ]]; then
24+
cargo build --release -p taskers-macos-ffi --target aarch64-apple-darwin
25+
cargo build --release -p taskers-macos-ffi --target x86_64-apple-darwin
26+
cargo build --release -p taskers-cli --bin taskersctl --target aarch64-apple-darwin
27+
cargo build --release -p taskers-cli --bin taskersctl --target x86_64-apple-darwin
28+
else
29+
cargo build --release -p taskers-macos-ffi
30+
cargo build --release -p taskers-cli --bin taskersctl
31+
fi
1432
popd >/dev/null
1533

16-
cp "${ROOT_DIR}/target/release/libtaskers_macos_ffi.a" "${BUILD_DIR}/libtaskers_macos_ffi.a"
17-
cp "${ROOT_DIR}/target/release/taskersctl" "${BUILD_DIR}/bin/taskersctl"
34+
if [[ "${BUILD_MODE}" == "universal" ]]; then
35+
lipo -create \
36+
-output "${BUILD_DIR}/libtaskers_macos_ffi.a" \
37+
"${ROOT_DIR}/target/aarch64-apple-darwin/release/libtaskers_macos_ffi.a" \
38+
"${ROOT_DIR}/target/x86_64-apple-darwin/release/libtaskers_macos_ffi.a"
39+
lipo -create \
40+
-output "${BUILD_DIR}/bin/taskersctl" \
41+
"${ROOT_DIR}/target/aarch64-apple-darwin/release/taskersctl" \
42+
"${ROOT_DIR}/target/x86_64-apple-darwin/release/taskersctl"
43+
else
44+
cp "${ROOT_DIR}/target/release/libtaskers_macos_ffi.a" "${BUILD_DIR}/libtaskers_macos_ffi.a"
45+
cp "${ROOT_DIR}/target/release/taskersctl" "${BUILD_DIR}/bin/taskersctl"
46+
fi
1847
chmod +x "${BUILD_DIR}/bin/taskersctl"
1948

2049
pushd "${GHOSTTY_DIR}" >/dev/null
@@ -25,7 +54,7 @@ zig build \
2554
-Demit-xcframework=true \
2655
-Demit-macos-app=false \
2756
"-Dversion-string=${GHOSTTY_VERSION}" \
28-
-Dxcframework-target=native
57+
"-Dxcframework-target=${BUILD_MODE}"
2958
popd >/dev/null
3059

3160
rm -rf "${BUILD_DIR}/GhosttyKit.xcframework"
@@ -34,3 +63,5 @@ cp -R "${GHOSTTY_DIR}/macos/GhosttyKit.xcframework" "${BUILD_DIR}/GhosttyKit.xcf
3463
rm -rf "${BUILD_DIR}/resources/ghostty" "${BUILD_DIR}/resources/terminfo"
3564
cp -R "${GHOSTTY_DIR}/zig-out/share/ghostty" "${BUILD_DIR}/resources/ghostty"
3665
cp -R "${GHOSTTY_DIR}/zig-out/share/terminfo" "${BUILD_DIR}/resources/terminfo"
66+
67+
printf '%s\n' "${BUILD_MODE}" > "${MODE_STAMP}"

0 commit comments

Comments
 (0)