From b1d1af2153ec36b66dc3f33be2f133da5830dc73 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 20 Apr 2024 17:41:10 +0200 Subject: [PATCH] Add M1 build for MacOS --- .github/workflows/build.yml | 36 ++++++++++++++++++++++++++++++------ setup/macos/build.sh | 24 ++++++++++++++++++------ 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 492bb5f4..dc057885 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: - name: Python Setup uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" architecture: x64 - name: Install Packages (apt) @@ -42,13 +42,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.11"] + python-version: ["3.12"] linux-tag: ["manylinux_2_24_x86_64", "manylinux_2_28_x86_64"] steps: - name: Python Setup uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" architecture: x64 - name: Install Packages (pip) @@ -74,7 +74,7 @@ jobs: if-no-files-found: error retention-days: 1 - buildMac: + buildMac-AMD64: needs: buildAssets runs-on: macos-12 steps: @@ -88,12 +88,36 @@ jobs: path: novelwriter/assets - name: Build App Bundle - run: ./setup/macos/build.sh + run: ./setup/macos/build.sh amd64 - name: Upload DMG uses: actions/upload-artifact@v4 with: - name: MacOS-DMG + name: MacOS-AMD64-DMG + path: dist_macos + if-no-files-found: error + retention-days: 1 + + buildMac-M1: + needs: buildAssets + runs-on: macos-14 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + name: nw-assets + path: novelwriter/assets + + - name: Build App Bundle + run: ./setup/macos/build.sh arm64 + + - name: Upload DMG + uses: actions/upload-artifact@v4 + with: + name: MacOS-M1-DMG path: dist_macos if-no-files-found: error retention-days: 1 diff --git a/setup/macos/build.sh b/setup/macos/build.sh index 9fff747b..1304488a 100755 --- a/setup/macos/build.sh +++ b/setup/macos/build.sh @@ -1,5 +1,17 @@ #! /bin/bash +if [ -z "$1"]; then + ARCH="amd64" +else + ARCH="$1" +fi + +if [ $ARCH == "amd64 "]; then + CONDA="x86_64" +else + CONDA="$ARCH" +fi + # Use RAM disk if possible if [ -d /dev/shm ]; then TEMP_BASE=/dev/shm @@ -76,9 +88,9 @@ pushd "$BUILD_DIR"/ || exit 1 # --- Create Miniconda Env ---------------------------------------------------------------------- # 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 +curl -LO https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-$CONDA.sh +bash Miniconda3-latest-MacOSX-$CONDA.sh -b -p ~/miniconda -f +rm Miniconda3-latest-MacOSX-$CONDA.sh export PATH="$HOME/miniconda/bin:$PATH" echo "Creating Conda env ..." @@ -123,7 +135,7 @@ cp $SRC_DIR/setup/macos/novelwriter.icns novelWriter.app/Contents/Resources/ # Create entry script echo "Creating entry script ..." -cat > novelWriter.app/Contents/MacOS/novelWriter <<\EOF +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 $@ @@ -173,8 +185,8 @@ brew install create-dmg 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}"-amd64.dmg "$BUILD_DIR"/ + --app-drop-link 600 185 $RLS_DIR/novelWriter-"${VERSION}"-$ARCH.dmg "$BUILD_DIR"/ pushd $RLS_DIR || exit 1 -shasum -a 256 novelWriter-"${VERSION}"-amd64.dmg | tee novelWriter-"${VERSION}"-amd64.dmg.sha256 +shasum -a 256 novelWriter-"${VERSION}"-$ARCH.dmg | tee novelWriter-"${VERSION}"-$ARCH.dmg.sha256 popd || exit 1