From d71a277af7074cd37479ea0be57973ea00bf23fc Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 12 Feb 2023 22:11:32 +0100 Subject: [PATCH] Change order of macos build, and add more output --- .github/workflows/build.yml | 4 +- setup/macos/build.sh | 77 ++++++++++++++++++++++++------------- 2 files changed, 52 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57581b02..88b16ebc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,11 +65,11 @@ jobs: with: name: novelWriter-${{ env.VERSION }}-macos.app.zip path: dist_macos/novelWriter-${{ env.VERSION }}.app.zip - # retention-days: 1 + retention-days: 1 - name: Upload DMG uses: actions/upload-artifact@v3 with: name: novelWriter-${{ env.VERSION }}-macos.dmg path: dist_macos/novelWriter-${{ env.VERSION }}.dmg - # retention-days: 1 + retention-days: 1 diff --git a/setup/macos/build.sh b/setup/macos/build.sh index e3e8e2ff..ae7ff30f 100755 --- a/setup/macos/build.sh +++ b/setup/macos/build.sh @@ -1,6 +1,6 @@ #! /bin/bash -# use RAM disk if possible +# Use RAM disk if possible if [ -d /dev/shm ]; then TEMP_BASE=/dev/shm else @@ -8,11 +8,8 @@ else fi BUILD_DIR=$(mktemp -d "$TEMP_BASE/novelWriter-build-XXXXXX") - SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - SRC_DIR="$SCRIPT_DIR/../.." - RLS_DIR="$SRC_DIR/dist_macos" echo "Script Dir: $SCRIPT_DIR" @@ -22,17 +19,18 @@ cleanup () { rm -rf "$BUILD_DIR" fi } - trap cleanup EXIT echo "Building in: $BUILD_DIR" OLD_CWD="$(pwd)" - VERSION="$(awk '/^__version__/{print substr($NF,2,length($NF)-2)}' $SRC_DIR/novelwriter/__init__.py)" pushd "$SRC_DIR" || exit 1 +# --- Prepare Files ----------------------------------------------------------------------------- # + +echo "Generating Info.plist" python3 setup.py gen-plist if [ -f $SRC_DIR/setup/macos/Info.plist ]; then echo "Found: setup/macos/Info.plist" @@ -40,8 +38,10 @@ else echo "Missing: setup/macos/Info.plist" exit 1 fi +echo "" # Check that other assets are present +echo "Checking assets" if [ -f $SRC_DIR/novelwriter/assets/sample.zip ]; then echo "Found: novelwriter/assets/sample.zip" else @@ -60,40 +60,51 @@ else echo "Missing: novelwriter/assets/i18n/nw_en_US.qm" exit 1 fi +echo "" +echo "Content of current dir:" ls -lah . +echo "" popd || exit 1 - pushd "$BUILD_DIR"/ || exit 1 -echo "Downloading Miniconda ..." +# --- Create Miniconda Env ---------------------------------------------------------------------- # + # install Miniconda, a self-contained Python distribution +echo "Downloading Miniconda ..." curl -LO https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh bash Miniconda3-latest-MacOSX-x86_64.sh -b -p ~/miniconda -f rm Miniconda3-latest-MacOSX-x86_64.sh export PATH="$HOME/miniconda/bin:$PATH" +echo "" echo "Creating conda env ..." # create conda env conda create -n novelWriter -c conda-forge python=3.10 --yes source activate novelWriter +echo "" echo "installing dictionaries ..." conda install -c conda-forge enchant hunspell-en --yes +echo "" -echo "installing python deps ..." -# install dependencies +# Install dependencies +echo "installing python dependencies ..." pip install -r "$SRC_DIR/requirements.txt" -# leave conda env +# Leave conda env conda deactivate +echo "" + +# --- Build App --------------------------------------------------------------------------------- # echo "Building app bundle ..." # create .app Framework mkdir -p novelWriter.app/Contents/ mkdir novelWriter.app/Contents/MacOS novelWriter.app/Contents/Resources novelWriter.app/Contents/Resources/novelWriter cp $SRC_DIR/setup/macos/Info.plist novelWriter.app/Contents/Info.plist +echo "" echo "Copying miniconda env to bundle ..." cp -R ~/miniconda/envs/novelWriter/* novelWriter.app/Contents/Resources/ @@ -111,24 +122,29 @@ for file in "${FILES_COPY[@]}"; do done cp $SRC_DIR/setup/macos/novelwriter.icns novelWriter.app/Contents/Resources/ +echo "" -# create entry script +# Create entry script +echo "Creating entry script ..." cat > novelWriter.app/Contents/MacOS/novelWriter <<\EOF #!/bin/bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" $DIR/../Resources/bin/python -sE $DIR/../Resources/novelWriter/novelWriter.py $@ EOF -# make executable +# Make it executable chmod a+x novelWriter.app/Contents/MacOS/novelWriter +echo "" -#do codesigning -#echo "Signing bundle ..." -#sudo codesign --sign - --deep --force --entitlements "$SCRIPT_DIR/../macos/App.entitlements" --options runtime "novelWriter.app/Contents/MacOS/novelWriter" +# Do codesigning +# echo "Signing bundle ..." +# sudo codesign --sign - --deep --force --entitlements "$SCRIPT_DIR/../macos/App.entitlements" --options runtime "novelWriter.app/Contents/MacOS/novelWriter" -# remove bloat +# Remove bloat pushd novelWriter.app/Contents/Resources || exit 1 +# --- Cleanup ----------------------------------------------------------------------------------- # + echo "Cleaning unused files from bundle ..." # cleanup commands HERE find . -type d -iname '__pycache__' -print0 | xargs -0 rm -r @@ -151,21 +167,28 @@ rm lib/python3.*/site-packages/PyQt5/Qt/lib/libQt5WebEngine* || true popd || exit 1 popd || exit 1 +echo "" + +# --- Create App Bundle-------------------------------------------------------------------------- # echo "Packageing App ..." - mkdir -p $RLS_DIR -# generate .dmg - -brew install create-dmg -# "--skip-jenkins" is a temporary workaround for https://github.com/create-dmg/create-dmg/issues/72 -create-dmg --volname "novelWriter $VERSION" --volicon $SRC_DIR/setup/macos/novelwriter.icns \ - --window-pos 200 120 --window-size 800 400 --icon-size 100 --icon novelWriter.app 200 190 --hide-extension novelWriter.app \ - --app-drop-link 600 185 $RLS_DIR/novelWriter-"${VERSION}".dmg "$BUILD_DIR"/ - pushd $BUILD_DIR || exit 1 zip -qr novelWriter.app.zip novelWriter.app popd || exit 1 -mv $BUILD_DIR/novelWriter.app.zip $RLS_DIR/novelWriter-"${VERSION}".app.zip +mv -v $BUILD_DIR/novelWriter.app.zip $RLS_DIR/novelWriter-"${VERSION}"-macos.app.zip +echo "" + +# --- Create DMG -------------------------------------------------------------------------------- # + +# Generate .dmg +echo "Packageing DMG ..." +brew install create-dmg + +# "--skip-jenkins" is a temporary workaround for https://github.com/create-dmg/create-dmg/issues/72 +create-dmg --volname "novelWriter $VERSION" --volicon $SRC_DIR/setup/macos/novelwriter.icns \ + --window-pos 200 120 --window-size 800 400 --icon-size 100 \ + --icon novelWriter.app 200 190 --hide-extension novelWriter.app \ + --app-drop-link 600 185 $RLS_DIR/novelWriter-"${VERSION}"-macos.dmg "$BUILD_DIR"/