2020-05-23 23:41:19 +03:00
|
|
|
#!/bin/bash
|
2021-10-04 18:56:48 +03:00
|
|
|
|
2022-03-17 19:13:27 +03:00
|
|
|
set -o errexit -o nounset
|
2021-10-04 18:56:48 +03:00
|
|
|
|
2022-08-04 20:03:50 +03:00
|
|
|
git status
|
|
|
|
git submodule
|
|
|
|
|
2020-12-24 12:43:36 +03:00
|
|
|
# If the env variable NOTARIZE and the username and password variables are
|
2021-05-12 23:12:30 +03:00
|
|
|
# set, this will attempt to Notarize the signed DMG.
|
2020-06-07 02:18:43 +03:00
|
|
|
|
2020-06-24 06:47:06 +03:00
|
|
|
if [ ! "$CHIA_INSTALLER_VERSION" ]; then
|
2020-11-01 05:35:04 +03:00
|
|
|
echo "WARNING: No environment variable CHIA_INSTALLER_VERSION set. Using 0.0.0."
|
|
|
|
CHIA_INSTALLER_VERSION="0.0.0"
|
2020-06-05 07:45:30 +03:00
|
|
|
fi
|
2020-06-07 02:18:43 +03:00
|
|
|
echo "Chia Installer Version is: $CHIA_INSTALLER_VERSION"
|
2020-06-05 07:45:30 +03:00
|
|
|
|
2022-08-25 04:13:40 +03:00
|
|
|
echo "Installing npm utilities"
|
|
|
|
cd npm_macos || exit 1
|
2022-01-20 03:52:20 +03:00
|
|
|
npm ci
|
|
|
|
PATH=$(npm bin):$PATH
|
2022-08-25 04:13:40 +03:00
|
|
|
cd .. || exit 1
|
2020-05-23 23:41:19 +03:00
|
|
|
|
|
|
|
echo "Create dist/"
|
2020-05-20 10:41:10 +03:00
|
|
|
sudo rm -rf dist
|
|
|
|
mkdir dist
|
2020-05-23 23:41:19 +03:00
|
|
|
|
2021-03-19 01:04:22 +03:00
|
|
|
echo "Create executables with pyinstaller"
|
2021-03-22 22:36:05 +03:00
|
|
|
SPEC_FILE=$(python -c 'import chia; print(chia.PYINSTALLER_SPEC_PATH)')
|
2021-03-24 02:05:42 +03:00
|
|
|
pyinstaller --log-level=INFO "$SPEC_FILE"
|
2021-04-04 04:21:43 +03:00
|
|
|
LAST_EXIT_CODE=$?
|
|
|
|
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
|
|
|
|
echo >&2 "pyinstaller failed!"
|
|
|
|
exit $LAST_EXIT_CODE
|
|
|
|
fi
|
2021-12-09 01:39:01 +03:00
|
|
|
cp -r dist/daemon ../chia-blockchain-gui/packages/gui
|
2021-01-10 01:55:10 +03:00
|
|
|
|
2021-12-09 01:39:01 +03:00
|
|
|
# Change to the gui package
|
2022-08-25 04:13:40 +03:00
|
|
|
cd ../chia-blockchain-gui/packages/gui || exit 1
|
2021-12-09 01:39:01 +03:00
|
|
|
|
2021-10-01 20:22:22 +03:00
|
|
|
# sets the version for chia-blockchain in package.json
|
|
|
|
brew install jq
|
|
|
|
cp package.json package.json.orig
|
|
|
|
jq --arg VER "$CHIA_INSTALLER_VERSION" '.version=$VER' package.json > temp.json && mv temp.json package.json
|
|
|
|
|
2022-08-25 04:13:40 +03:00
|
|
|
echo "Building macOS Electron app"
|
|
|
|
OPT_ARCH="--x64"
|
|
|
|
if [ "$(arch)" = "arm64" ]; then
|
|
|
|
OPT_ARCH="--arm64"
|
|
|
|
fi
|
|
|
|
PRODUCT_NAME="Chia"
|
2022-08-25 23:59:58 +03:00
|
|
|
if [ "$NOTARIZE" == true ]; then
|
|
|
|
echo "Setting credentials for signing"
|
|
|
|
export CSC_LINK=$APPLE_DEV_ID_APP
|
|
|
|
export CSC_KEY_PASSWORD=$APPLE_DEV_ID_APP_PASS
|
|
|
|
else
|
|
|
|
echo "Not on ci or no secrets so not signing"
|
|
|
|
export CSC_IDENTITY_AUTO_DISCOVERY=false
|
|
|
|
fi
|
2022-08-25 04:13:40 +03:00
|
|
|
echo electron-builder build --mac "${OPT_ARCH}" --config.productName="$PRODUCT_NAME"
|
|
|
|
electron-builder build --mac "${OPT_ARCH}" --config.productName="$PRODUCT_NAME"
|
2021-01-10 01:55:10 +03:00
|
|
|
LAST_EXIT_CODE=$?
|
2022-08-25 04:13:40 +03:00
|
|
|
ls -l dist/mac*/chia.app/Contents/Resources/app.asar
|
2021-10-01 20:22:22 +03:00
|
|
|
|
|
|
|
# reset the package.json to the original
|
|
|
|
mv package.json.orig package.json
|
|
|
|
|
2021-01-10 01:55:10 +03:00
|
|
|
if [ "$LAST_EXIT_CODE" -ne 0 ]; then
|
2022-08-25 04:13:40 +03:00
|
|
|
echo >&2 "electron-builder failed!"
|
2021-01-10 01:55:10 +03:00
|
|
|
exit $LAST_EXIT_CODE
|
|
|
|
fi
|
2020-12-24 12:43:36 +03:00
|
|
|
|
2022-08-25 04:13:40 +03:00
|
|
|
mv dist/* ../../../build_scripts/dist/
|
|
|
|
cd ../../../build_scripts || exit 1
|
2020-05-23 23:41:19 +03:00
|
|
|
|
2020-06-07 02:18:43 +03:00
|
|
|
mkdir final_installer
|
2022-08-25 04:13:40 +03:00
|
|
|
DMG_NAME="chia-${CHIA_INSTALLER_VERSION}.dmg"
|
|
|
|
if [ "$(arch)" = "arm64" ]; then
|
|
|
|
mv dist/${DMG_NAME} dist/chia-${CHIA_INSTALLER_VERSION}-arm64.dmg
|
|
|
|
DMG_NAME=chia-${CHIA_INSTALLER_VERSION}-arm64.dmg
|
2021-01-10 01:55:10 +03:00
|
|
|
fi
|
2022-08-25 04:13:40 +03:00
|
|
|
mv dist/$DMG_NAME final_installer/
|
2020-12-24 12:43:36 +03:00
|
|
|
|
2022-08-11 00:04:59 +03:00
|
|
|
ls -lh final_installer
|
|
|
|
|
2021-10-05 16:22:03 +03:00
|
|
|
if [ "$NOTARIZE" == true ]; then
|
2020-12-24 12:43:36 +03:00
|
|
|
echo "Notarize $DMG_NAME on ci"
|
2022-08-25 04:13:40 +03:00
|
|
|
cd final_installer || exit 1
|
2022-08-11 00:04:59 +03:00
|
|
|
notarize-cli --file="$DMG_NAME" --bundle-id net.chia.blockchain \
|
2020-12-25 02:18:10 +03:00
|
|
|
--username "$APPLE_NOTARIZE_USERNAME" --password "$APPLE_NOTARIZE_PASSWORD"
|
2020-12-24 12:43:36 +03:00
|
|
|
echo "Notarization step complete"
|
|
|
|
else
|
2021-01-18 06:47:48 +03:00
|
|
|
echo "Not on ci or no secrets so skipping Notarize"
|
2020-12-24 12:43:36 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Notes on how to manually notarize
|
|
|
|
#
|
2021-05-12 23:12:30 +03:00
|
|
|
# Ask for username and password. password should be an app specific password.
|
2020-12-24 12:43:36 +03:00
|
|
|
# Generate app specific password https://support.apple.com/en-us/HT204397
|
|
|
|
# xcrun altool --notarize-app -f Chia-0.1.X.dmg --primary-bundle-id net.chia.blockchain -u username -p password
|
|
|
|
# xcrun altool --notarize-app; -should return REQUEST-ID, use it in next command
|
|
|
|
#
|
2021-05-12 23:12:30 +03:00
|
|
|
# Wait until following command return a success message".
|
|
|
|
# watch -n 20 'xcrun altool --notarization-info {REQUEST-ID} -u username -p password'.
|
|
|
|
# It can take a while, run it every few minutes.
|
2020-12-24 12:43:36 +03:00
|
|
|
#
|
2021-05-12 23:12:30 +03:00
|
|
|
# Once that is successful, execute the following command":
|
2020-12-24 12:43:36 +03:00
|
|
|
# xcrun stapler staple Chia-0.1.X.dmg
|
|
|
|
#
|
2021-05-12 23:12:30 +03:00
|
|
|
# Validate DMG:
|
2020-12-24 12:43:36 +03:00
|
|
|
# xcrun stapler validate Chia-0.1.X.dmg
|