Skip to content

Commit

Permalink
Add Bundle Support + Fix Workflow
Browse files Browse the repository at this point in the history
Fixes the github workflow and adds the option to install Lovey on macOS as an app bundle in the user applications folder, complete with a unique icon. Updates Readme to accomodate.
  • Loading branch information
MisutaaAsriel committed Jan 2, 2025
1 parent 3224915 commit 07123e0
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 4 deletions.
52 changes: 49 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ jobs:
echo "|--|--|" >> NOTE.md
echo "|Windows|[lovely-x86_64-pc-windows-msvc.zip](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-x86_64-pc-windows-msvc.zip)|" >> NOTE.md
echo "|Mac (Arm)|[lovely-aarch64-apple-darwin.tar.gz](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-aarch64-apple-darwin.tar.gz)|" >> NOTE.md
echo "|Mac (x86)|[lovely-x86_64-apple-darwin.tar.gz](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-x86_64-apple-darwin.tar.gz)|" >> NOTE.md
echo "|Mac (Arm) (Installer)|[lovely-aarch64-apple-darwin-installer.tar.gz](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-aarch64-apple-darwin.tar.gz)|" >> NOTE.md
echo "|Mac (x86)|[lovely-x86_64-apple-darwin-installer.tar.gz](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-x86_64-apple-darwin.tar.gz)|" >> NOTE.md
echo "|Mac (x86) (Installer)|[lovely-x86_64-apple-darwin-installer.tar.gz](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-x86_64-apple-darwin-installer.tar.gz)|" >> NOTE.md
gh release create ${{ github.ref_name }} \
--title "${{ github.ref_name }}" \
Expand Down Expand Up @@ -92,11 +94,11 @@ jobs:
pip3 install cargo-zigbuild
- name: Build
run: cargo zigbuild --target ${{ matrix.target }} --package lovely-mac --release
run: cargo zigbuild --target ${{ matrix.target }} --package lovely-unix --release

- name: Compress tar.gz
run: |
cp ./crates/lovely-mac/run_lovely.sh ./target/${{ matrix.target }}/release/
cp ./crates/lovely-unix/run_lovely_macos.sh ./target/${{ matrix.target }}/release/run_lovely.sh
cd ./target/${{ matrix.target }}/release/
tar czfv lovely-${{ matrix.target }}.tar.gz liblovely.dylib run_lovely.sh
mv "lovely-${{ matrix.target }}.tar.gz" ${{ github.workspace }}
Expand All @@ -106,3 +108,47 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
gh release upload ${{ github.ref_name }} lovely-${{ matrix.target }}.tar.gz
build-mac-bundle:
needs: prepare
strategy:
matrix:
target:
- x86_64-apple-darwin
- aarch64-apple-darwin
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup toolchain
uses: dtolnay/rust-toolchain@nightly
with:
target: ${{ matrix.target }}

- name: Install Mac SDK
run: |
curl -L "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.9.sdk.tar.xz" | tar -J -x -C /opt
curl -L "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz" | tar -J -x -C /opt
echo "SDKROOT=/opt/MacOSX11.3.sdk" >> $GITHUB_ENV
- name: Install cargo-zigbuild
run: |
pip3 install cargo-zigbuild
- name: Build
run: cargo zigbuild --target ${{ matrix.target }} --package lovely-unix --release

- name: Compress tar.gz
run: |
cp ./crates/lovely-unix/install_lovely_macos_bundle.sh ./target/${{ matrix.target }}/release/install_lovely.sh
cp -R ./crates/lovely-unix/resources-mac ./target/${{ matrix.target }}/release/assets
cd ./target/${{ matrix.target }}/release/
tar czfv lovely-${{ matrix.target }}-installer.tar.gz liblovely.dylib install_lovely.sh assets
mv "lovely-${{ matrix.target }}-installer.tar.gz" ${{ github.workspace }}
- name: Submit build artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
gh release upload ${{ github.ref_name }} lovely-${{ matrix.target }}-installer.tar.gz
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ Lovely is a lua injector which embeds code into a [LÖVE 2d](https://love2d.org/

### Mac

#### Bundle Installation (Easy)
1. Download the [latest release](https://github.com/ethangreen-dev/lovely-injector/releases) for Mac. If you have an M-series CPU (M1, M2, etc.) then this will be `lovely-aarch64-apple-darwin-installer.tar.gz`. If you have an Intel CPU then it will be `lovely-x86_64-apple-darwin-installer.tar.gz`
2. Open the .zip archive, copy `assets`, `liblovely.dylib` and `install_lovely.sh` into the game directory. You can navigate to the game's directory by right-clicking the game in Steam, hovering "Manage", and selecting "Browse local files".
3. Run `install_lovely.sh`, which will generate an app bundle, `Balatro + Mods.app`, in your user applications directory (`~/Applications`).
4. Put one or more mods into the Mac mod directory (NOT the same as the game directory). This should be `/Users/$USER/Library/Application Support/Balatro/Mods` where `$USER` is your username (if you are modding Balatro).\
If you can't find this folder, try pressing `Shift-Command-.` (period) to show hidden files in Finder.
5. Open `Balatro + Mods.app`, either directly from `~/Applications`, or from Launchpad, and enjoy.

#### Classic Installation (Advanced)
1. Download the [latest release](https://github.com/ethangreen-dev/lovely-injector/releases) for Mac. If you have an M-series CPU (M1, M2, etc.) then this will be `lovely-aarch64-apple-darwin.tar.gz`. If you have an Intel CPU then it will be `lovely-x86_64-apple-darwin.tar.gz`
2. Open the .zip archive, copy `liblovely.dylib` and `run_lovely.sh` into the game directory. You can navigate to the game's directory by right-clicking the game in Steam, hovering "Manage", and selecting "Browse local files".
3. Put one or more mods into the Mac mod directory (NOT the same as the game directory). This should be `/Users/$USER/Library/Application Support/Balatro/Mods` where `$USER` is your username (if you are modding Balatro).\
Expand Down
47 changes: 47 additions & 0 deletions crates/lovely-unix/install_lovely_macos_bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
gamename="Balatro"

workingpath=$(cd "$(dirname "$0")"; pwd)
assetpath="${workingpath}/assets/"

if ! [ -d "${workingpath}/${gamename}.app" ]; then
echo
echo "Balatro not found. Did you place everything in the right directory?"
echo
read -n1 -r -p "Press any key to exit..." key
exit
fi

gamebundle="${workingpath}/${gamename}.app"

bundlepath="/Users/$USER/Applications/${gamename} + Mods.app"
contentpath="${bundlepath}/Contents"

echo
echo "Generating bundle..."
mkdir -p "${contentpath}"
cd "${contentpath}"
mkdir MacOS
mkdir Resources

echo
echo "Copying assets..."
ln -s "${gamebundle}" ./MacOS/
mv "${assetpath}/run_lovely.sh" ./MacOS/run_lovely
mv "${assetpath}/info.plist" ./
mv "${workingpath}/liblovely.dylib" ./MacOS/
mv "${assetpath}/application.icns" ./Resources/

chmod +x ./MacOS/run_lovely
echo "Signing application..."
codesign -s - --deep "${bundlepath}/Contents/MacOS/run_lovely"

echo
echo "Cleaning up..."
rm "${workingpath}/install_lovely.sh"
rm -rf "${workingpath}/assets"

echo
read -n1 -r -p "Installation complete! Press any key to exit..." key
open /Users/$USER/Applications
exit
38 changes: 38 additions & 0 deletions crates/lovely-unix/resources-mac/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>run_lovely</string>
<key>CFBundleIconFile</key>
<string>application.icns</string>
<key>CFBundleIdentifier</key>
<string>com.Balatro.localthunk.modded</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Balatro</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>LoVe</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>LSMinimumSystemVersion</key>
<string>10.7</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>© 2024 LocalThunk Inc.</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<false/>
</dict>
</plist>
Binary file added crates/lovely-unix/resources-mac/application.icns
Binary file not shown.
8 changes: 8 additions & 0 deletions crates/lovely-unix/resources-mac/run_lovely.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
gamename="Balatro"
workingpath=$(cd "$(dirname "$0")"; pwd)

export DYLD_INSERT_LIBRARIES=liblovely.dylib

cd "${workingpath}"
./$gamename.app/Contents/MacOS/love "$@"
16 changes: 15 additions & 1 deletion crates/lovely-unix/run_lovely_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
gamename="Balatro"
defaultpath="/Users/$USER/Library/Application Support/Steam/steamapps/common/$gamename"

if ! [ -d "${workingpath}/${gamename}.app" ]; then
if ! [ -d cd "${defaultpath}/${gamename}.app" ]; then
echo
echo "Balatro not found. Did you place this in the right directory?"
echo
read -n1 -r -p "Press any key to exit..." key
exit
else
cd "$defaultpath"
fi
else
cd "$workingpath"
fi

export DYLD_INSERT_LIBRARIES=liblovely.dylib

cd "$defaultpath"

./$gamename.app/Contents/MacOS/love "$@"

0 comments on commit 07123e0

Please sign in to comment.