zed/script/bundle

69 lines
3 KiB
Text
Raw Normal View History

#!/bin/bash
set -e
export ZED_BUNDLE=true
echo "Installing cargo bundle"
cargo install cargo-bundle --version 0.5.0
2022-07-11 16:29:27 +00:00
rustup target add wasm32-wasi
# Deal with versions of macOS that don't include libstdc++ headers
export CXXFLAGS="-stdlib=libc++"
echo "Compiling binaries"
cargo build --release --package zed --target aarch64-apple-darwin
cargo build --release --package zed --target x86_64-apple-darwin
cargo build --release --package cli --target aarch64-apple-darwin
cargo build --release --package cli --target x86_64-apple-darwin
echo "Creating application bundle"
(cd crates/zed && cargo bundle --release --target x86_64-apple-darwin)
echo "Creating fat binaries"
lipo \
-create \
target/{x86_64-apple-darwin,aarch64-apple-darwin}/release/Zed \
-output \
target/x86_64-apple-darwin/release/bundle/osx/Zed.app/Contents/MacOS/zed
lipo \
-create \
target/{x86_64-apple-darwin,aarch64-apple-darwin}/release/cli \
-output \
target/x86_64-apple-darwin/release/bundle/osx/Zed.app/Contents/MacOS/cli
2021-09-11 05:11:22 +00:00
if [[ -n $MACOS_CERTIFICATE && -n $MACOS_CERTIFICATE_PASSWORD && -n $APPLE_NOTARIZATION_USERNAME && -n $APPLE_NOTARIZATION_PASSWORD ]]; then
echo "Signing bundle with Apple-issued certificate"
security create-keychain -p $MACOS_CERTIFICATE_PASSWORD zed.keychain || echo ""
2021-09-11 04:51:45 +00:00
security default-keychain -s zed.keychain
security unlock-keychain -p $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
2021-09-11 04:51:45 +00:00
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $MACOS_CERTIFICATE_PASSWORD zed.keychain
2021-09-11 05:11:22 +00:00
/usr/bin/codesign --force --deep --timestamp --options runtime --sign "Zed Industries, Inc." target/x86_64-apple-darwin/release/bundle/osx/Zed.app -v
security default-keychain -s login.keychain
else
echo "One or more of the following variables are missing: MACOS_CERTIFICATE, MACOS_CERTIFICATE_PASSWORD, APPLE_NOTARIZATION_USERNAME, APPLE_NOTARIZATION_PASSWORD"
echo "Performing an ad-hoc signature, but this bundle should not be distributed"
codesign --force --deep --sign - target/x86_64-apple-darwin/release/bundle/osx/Zed.app -v
fi
2021-09-11 05:11:22 +00:00
echo "Creating 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
2021-09-11 05:11:22 +00:00
if [[ -n $MACOS_CERTIFICATE && -n $MACOS_CERTIFICATE_PASSWORD && -n $APPLE_NOTARIZATION_USERNAME && -n $APPLE_NOTARIZATION_PASSWORD ]]; then
echo "Notarizing DMG with Apple"
npm install -g notarize-cli
npx notarize-cli --file target/release/Zed.dmg --bundle-id dev.zed.Zed --username $APPLE_NOTARIZATION_USERNAME --password $APPLE_NOTARIZATION_PASSWORD
fi
# 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