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
|
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"
|
2023-09-18 19:29:06 +03:00
|
|
|
SPEC_FILE=$(python -c 'import sys; from pathlib import Path; path = Path(sys.argv[1]); print(path.absolute().as_posix())' "pyinstaller.spec")
|
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-01-10 01:55:10 +03:00
|
|
|
|
2023-06-22 00:51:05 +03:00
|
|
|
|
|
|
|
# Creates a directory of licenses
|
|
|
|
echo "Building pip and NPM license directory"
|
|
|
|
pwd
|
|
|
|
bash ./build_license_directory.sh
|
|
|
|
|
|
|
|
cp -r dist/daemon ../chia-blockchain-gui/packages/gui
|
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
|
2023-05-18 21:18:45 +03:00
|
|
|
export PUBLISH_FOR_PULL_REQUEST=true
|
|
|
|
export CSC_FOR_PULL_REQUEST=true
|
2022-08-25 23:59:58 +03:00
|
|
|
else
|
|
|
|
echo "Not on ci or no secrets so not signing"
|
|
|
|
export CSC_IDENTITY_AUTO_DISCOVERY=false
|
|
|
|
fi
|
2023-12-18 20:12:04 +03:00
|
|
|
echo npx electron-builder build --mac "${OPT_ARCH}" --config.productName="$PRODUCT_NAME" --config.mac.minimumSystemVersion="11" --config ../../../build_scripts/electron-builder.json
|
|
|
|
npx electron-builder build --mac "${OPT_ARCH}" --config.productName="$PRODUCT_NAME" --config.mac.minimumSystemVersion="11" --config ../../../build_scripts/electron-builder.json
|
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
|
2023-01-20 02:00:41 +03:00
|
|
|
mv dist/"${DMG_NAME}" dist/chia-"${CHIA_INSTALLER_VERSION}"-arm64.dmg
|
2022-08-25 04:13:40 +03:00
|
|
|
DMG_NAME=chia-${CHIA_INSTALLER_VERSION}-arm64.dmg
|
2021-01-10 01:55:10 +03:00
|
|
|
fi
|
2023-01-20 02:00:41 +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
|
2023-08-30 19:29:22 +03:00
|
|
|
xcrun notarytool submit --wait --apple-id "$APPLE_NOTARIZE_USERNAME" --password "$APPLE_NOTARIZE_PASSWORD" --team-id "$APPLE_TEAM_ID" "$DMG_NAME"
|
|
|
|
xcrun stapler staple "$DMG_NAME"
|
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
|
2023-08-30 19:29:22 +03:00
|
|
|
# xcrun notarytool submit --wait --apple-id username --password password --team-id team-id Chia-0.1.X.dmg
|
|
|
|
# Wait until the command returns a success message
|
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
|