Create zip of universal app package, clean up script (#318)

* Create zip of universal app package, clean up script

* add missing newlines
This commit is contained in:
Evan Simkowitz 2024-02-23 12:32:52 -08:00 committed by GitHub
parent 61de455b90
commit 7b692e2644
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 78 additions and 42 deletions

2
buildres/.gitignore vendored
View File

@ -1,3 +1,3 @@
temp/ */
*.zip *.zip
*.dmg *.dmg

View File

@ -1,11 +1,19 @@
#!/bin/bash #!/bin/bash
# This script is used to build the universal app for macOS
# assumes we have Wave-darwin-x64-[version].zip and Wave-darwin-arm64-[version].zip in current directory SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
VERSION=0.6.1
rm -rf temp rm -f *.zip *.dmg
rm -rf builds ZIP_DIR=$SCRIPT_DIR/zip
mkdir temp rm -rf $ZIP_DIR
mkdir temp/x64 mkdir $ZIP_DIR
TEMP_DIR=$SCRIPT_DIR/temp
rm -rf $TEMP_DIR
mkdir $TEMP_DIR
BUILDS_DIR=$SCRIPT_DIR/builds
rm -rf $BUILDS_DIR
# Download the builds zip
aws s3 cp s3://waveterm-github-artifacts/waveterm-builds.zip . aws s3 cp s3://waveterm-github-artifacts/waveterm-builds.zip .
BUILDS_ZIP=waveterm-builds.zip BUILDS_ZIP=waveterm-builds.zip
if ! [ -f $BUILDS_ZIP ]; then if ! [ -f $BUILDS_ZIP ]; then
@ -13,40 +21,67 @@ if ! [ -f $BUILDS_ZIP ]; then
exit 1; exit 1;
fi fi
echo "unzipping $BUILDS_ZIP" echo "unzipping $BUILDS_ZIP"
unzip -q $BUILDS_ZIP -d builds unzip -q $BUILDS_ZIP -d $BUILDS_DIR
X64_ZIP="builds/Wave-darwin-x64-$VERSION.zip" rm $BUILDS_ZIP
ARM64_ZIP="builds/Wave-darwin-arm64-$VERSION.zip"
if ! [ -f $X64_ZIP ]; then # Ensure we have exactly one of each build
echo "no $X64_ZIP found"; find_build()
exit 1; {
fi local BUILD_DIR=$1
if ! [ -f $ARM64_ZIP ]; then local BUILD_PATTERN=$2
echo "no $ARM64_ZIP found" local BUILD_PATH=$(find $BUILD_DIR -type f -iname "$BUILD_PATTERN")
exit 1; local NUM_MATCHES=$(echo $BUILD_PATH | wc -l)
if [ "0" -eq "$NUM_MATCHES" ]; then
echo "no $BUILD_NAME found in $BUILD_DIR"
exit 1
elif [ "1" -lt "$NUM_MATCHES" ]; then
echo "multiple $BUILD_NAME found in $BUILD_DIR"
exit 1
fi fi
echo $BUILD_PATH
}
X64_ZIP=$(find_build $BUILDS_DIR "Wave-darwin-x64-*.zip")
ARM64_ZIP=$(find_build $BUILDS_DIR "Wave-darwin-arm64-*.zip")
set -e set -e
echo "unzipping version v$VERSION zip files"
ls -l "$X64_ZIP" "$ARM64_ZIP" echo "unzipping zip files"
unzip -q $X64_ZIP -d temp/x64 unzip -q $X64_ZIP -d $TEMP_DIR/x64
mkdir temp/arm64 unzip -q $ARM64_ZIP -d $TEMP_DIR/arm64
unzip -q $ARM64_ZIP -d temp/arm64 rm $ARM64_ZIP $X64_ZIP
lipo -create -output temp/wavesrv temp/x64/Wave.app/Contents/Resources/app/bin/wavesrv temp/arm64/Wave.app/Contents/Resources/app/bin/wavesrv
rm -rf temp/arm64/Wave.app/Contents/Resources/app # Create universal app and sign and notarize it
mv temp/x64/Wave.app/Contents/Resources/app temp/ TEMP_WAVE_DIR_ARM=$TEMP_DIR/x64/Wave.app
cp temp/wavesrv temp/app/bin/wavesrv TEMP_WAVE_DIR_X64=$TEMP_DIR/arm64/Wave.app
mkdir temp/x64/Wave.app/Contents/Resources/app TEMP_WAVE_DIR_UNIVERSAL=$TEMP_DIR/Wave.app
mkdir temp/arm64/Wave.app/Contents/Resources/app lipo -create -output $TEMP_DIR/wavesrv $TEMP_WAVE_DIR_X64/Contents/Resources/app/bin/wavesrv $TEMP_WAVE_DIR_ARM/Contents/Resources/app/bin/wavesrv
node build-universal.js rm -rf $TEMP_WAVE_DIR_ARM/Contents/Resources/app
rm -rf temp/Wave.app/Contents/Resources/app mv $TEMP_WAVE_DIR_X64/Contents/Resources/app temp/
mv temp/app temp/Wave.app/Contents/Resources/app cp $TEMP_DIR/wavesrv temp/app/bin/wavesrv
node osx-sign.js mkdir $TEMP_WAVE_DIR_ARM/Contents/Resources/app
mkdir $TEMP_WAVE_DIR_X64/Contents/Resources/app
node $SCRIPT_DIR/build-universal.js
rm -rf $TEMP_WAVE_DIR_UNIVERSAL/Contents/Resources/app
mv $TEMP_DIR/app $TEMP_WAVE_DIR_UNIVERSAL/Contents/Resources/app
node $SCRIPT_DIR/osx-sign.js
DEBUG=electron-notarize node osx-notarize.js DEBUG=electron-notarize node osx-notarize.js
echo "universal app creation success (build/sign/notarize)" echo "universal app creation success (build/sign/notarize)"
UVERSION=$(node -e 'console.log(require("../version.js"))')
UPACKAGE_NAME="waveterm-macos-universal-${UVERSION}"
echo "creating universal zip"
ditto $TEMP_WAVE_DIR_UNIVERSAL $ZIP_DIR/Wave.app
ZIP_NAME="${UPACKAGE_NAME}.zip"
cd $ZIP_DIR
zip -9yqr $ZIP_NAME Wave.app
mv $ZIP_NAME $BUILDS_DIR/
cd $SCRIPT_DIR
# Expects create-dmg repo to be cloned in the same parent directory as the waveterm repo.
echo "creating universal dmg" echo "creating universal dmg"
rm -f *.dmg DMG_NAME="${UPACKAGE_NAME}.dmg"
DMG_VERSION=$(node -e 'console.log(require("../version.js"))') $SCRIPT_DIR/../../create-dmg/create-dmg \
DMG_NAME="waveterm-macos-universal-${DMG_VERSION}.dmg"
../../create-dmg/create-dmg \
--volname "WaveTerm" \ --volname "WaveTerm" \
--window-pos 200 120 \ --window-pos 200 120 \
--window-size 600 300 \ --window-size 600 300 \
@ -55,8 +90,9 @@ DMG_NAME="waveterm-macos-universal-${DMG_VERSION}.dmg"
--hide-extension "Wave.app" \ --hide-extension "Wave.app" \
--app-drop-link 400 125 \ --app-drop-link 400 125 \
$DMG_NAME \ $DMG_NAME \
"temp/Wave.app" "$TEMP_WAVE_DIR_UNIVERSAL"
echo "success, created $DMG_NAME" echo "success, created $DMG_NAME"
mv $DMG_NAME builds/ mv $DMG_NAME $BUILDS_DIR/
rm builds/Wave-darwin-*.zip spctl -a -vvv -t install $TEMP_WAVE_DIR_UNIVERSAL/
spctl -a -vvv -t install temp/Wave.app/
rm -rf $TEMP_DIR $ZIP_DIR