mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 13:24:19 +00:00
45 lines
2 KiB
Bash
Executable file
45 lines
2 KiB
Bash
Executable file
#!/bin/bash
|
||
|
||
set -e
|
||
|
||
# Install cargo-bundle 0.5.0 if it's not already installed
|
||
cargo install cargo-bundle --version 0.5.0
|
||
|
||
# Build the app bundle for x86_64
|
||
pushd zed > /dev/null
|
||
cargo bundle --release --target x86_64-apple-darwin
|
||
popd > /dev/null
|
||
|
||
# Build the binary for aarch64 (Apple M1)
|
||
cargo build --release --target aarch64-apple-darwin
|
||
|
||
# Replace the bundle's binary with a "fat binary" that combines the two architecture-specific binaries
|
||
lipo -create target/x86_64-apple-darwin/release/Zed target/aarch64-apple-darwin/release/Zed -output target/x86_64-apple-darwin/release/bundle/osx/Zed.app/Contents/MacOS/zed
|
||
|
||
# Sign the app bundle with an ad-hoc signature so it runs on the M1. We need a real certificate but this works for now.
|
||
if [[ -z $MACOS_CERTIFICATE || -z $MACOS_CERTIFICATE_PASSWORD ]]; then
|
||
echo "Missing MACOS_CERTIFICATE and MACOS_CERTIFICATE_PASSWORD environment variables – performing ad-hoc signature"
|
||
codesign --force --deep -s - target/x86_64-apple-darwin/release/bundle/osx/Zed.app -v
|
||
else
|
||
echo "Signing bundle with Apple-issued certificate"
|
||
security create-keychain -p $MACOS_CERTIFICATE_PASSWORD zed.keychain || echo ""
|
||
security unlock-keychain -p $MACOS_CERTIFICATE_PASSWORD zed.keychain
|
||
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $MACOS_CERTIFICATE_PASSWORD zed.keychain
|
||
echo $MACOS_CERTIFICATE | base64 --decode > /tmp/zed-certificate.p12
|
||
security import /tmp/zed-certificate.p12 -k zed.keychain -P $MACOS_CERTIFICATE_PASSWORD -T /usr/bin/codesign
|
||
rm /tmp/zed-certificate.p12
|
||
security default-keychain -s zed.keychain
|
||
/usr/bin/codesign --force -s "Zed Industries, Inc." target/x86_64-apple-darwin/release/bundle/osx/Zed.app -v
|
||
fi
|
||
|
||
# Create a DMG
|
||
mkdir -p target/release
|
||
hdiutil create -volname Zed -srcfolder target/x86_64-apple-darwin/release/bundle/osx -ov -format UDZO target/release/Zed.dmg
|
||
|
||
# If -o option is specified, open the target/release directory in Finder to reveal the DMG
|
||
while getopts o flag
|
||
do
|
||
case "${flag}" in
|
||
o) open target/release;;
|
||
esac
|
||
done
|