From ef92239d03677d6396f770e39811af9acf07ca82 Mon Sep 17 00:00:00 2001 From: Thomas Horstink Date: Sat, 5 Oct 2024 18:42:16 +0200 Subject: [PATCH] app bundle --- .github/workflows/config.yml | 5 ++-- .github/workflows/macos/Info.plist | 26 ++++++++++++++++ .github/workflows/macos/create_app_bundle.sh | 11 +++++++ .github/workflows/macos/create_icons.sh | 31 ++++++++++++++++++++ 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/macos/Info.plist create mode 100644 .github/workflows/macos/create_app_bundle.sh create mode 100644 .github/workflows/macos/create_icons.sh diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 003e81a..9db0619 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -9,17 +9,18 @@ jobs: - uses: actions/checkout@v1 - name: "build mac" run: | - brew install glfw + brew install glfw svg2png git submodule update --init --recursive mkdir build cd build bash -c 'cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=ON ..' make + bash ../.github/workflows/macos/create_app_bundle.sh - name: Upload macos uses: actions/upload-artifact@v4 with: name: Farbart macos - path: build/symmetri/gui/Farbart + path: build/Farbart.tar.gz build-linux: runs-on: ubuntu-latest diff --git a/.github/workflows/macos/Info.plist b/.github/workflows/macos/Info.plist new file mode 100644 index 0000000..fe46c63 --- /dev/null +++ b/.github/workflows/macos/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleGetInfoString + Farbart + CFBundleExecutable + Farbart + CFBundleIdentifier + www.symmetri.net + CFBundleName + Farbart + CFBundleIconFile + farbart.icns + CFBundleShortVersionString + 0.01 + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + IFMajorVersion + 0 + IFMinorVersion + 1 + + diff --git a/.github/workflows/macos/create_app_bundle.sh b/.github/workflows/macos/create_app_bundle.sh new file mode 100644 index 0000000..6209d20 --- /dev/null +++ b/.github/workflows/macos/create_app_bundle.sh @@ -0,0 +1,11 @@ +#/bin/bash + +./symmetri/gui/generate_icon $(echo $((1 + $RANDOM % 9))) icon.svg +source ../.github/workflows/macos/create_icons.sh +svg_to_icns icon.svg +rm -r Farbart.app +mkdir -p Farbart.app/Contents Farbart.app/Contents/MacOS Farbart.app/Contents/Resources +cp icons/icon.icns Farbart.app/Contents/Resources/farbart.icns +cp ../.github/workflows/macos/Info.plist Farbart.app/Contents/Info.plist +cp symmetri/gui/Farbart Farbart.app/Contents/MacOS +tar -czf Farbart.tar.gz Farbart.app diff --git a/.github/workflows/macos/create_icons.sh b/.github/workflows/macos/create_icons.sh new file mode 100644 index 0000000..f011b64 --- /dev/null +++ b/.github/workflows/macos/create_icons.sh @@ -0,0 +1,31 @@ +# taken from +# https://gist.github.com/adriansr/1da9b18a8076b0f8a977a5eea0ae41ef + +function svg_to_icns(){ + local RESOLUTIONS=( + 16,16x16 + 32,16x16@2x + 32,32x32 + 64,32x32@2x + 128,128x128 + 256,128x128@2x + 256,256x256 + 512,256x256@2x + 512,512x512 + 1024,512x512@2x + ) + + for SVG in $@; do + BASE=$(basename "$SVG" | sed 's/\.[^\.]*$//') + ICONSET="$BASE.iconset" + ICONSET_DIR="./icons/$ICONSET" + mkdir -p "$ICONSET_DIR" + for RES in ${RESOLUTIONS[@]}; do + SIZE=$(echo $RES | cut -d, -f1) + LABEL=$(echo $RES | cut -d, -f2) + svg2png -w $SIZE -h $SIZE "$SVG" "$ICONSET_DIR"/icon_$LABEL.png + done + + iconutil -c icns "$ICONSET_DIR" + done +}