diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d5d1f94..2990a6e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,24 +21,22 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 + # macos-latest is aarch64, install x86_64 target - uses: dtolnay/rust-toolchain@stable - - name: Install cargo-bundle - run: cargo install cargo-bundle + with: + targets: x86_64-apple-darwin + + # build our two architectures + - name: Build (AArch64) + run: cargo build --target=aarch64-apple-darwin --release + - name: Build (x86_64) + run: cargo build --target=x86_64-apple-darwin --release - # cargo-bundle doesn't understand what to do about workspaces - - name: Bundle - run: | - cargo build --release - cp -r ./target ./crates/moonlight-installer/target - cd ./crates/moonlight-installer - cargo bundle --release - cd ../.. - rm -rf ./target - mv ./crates/moonlight-installer/target . - - name: Apply ad-hoc signature - run: codesign --force --deep -s - "target/release/bundle/osx/moonlight installer.app" + # packaging + - name: Create .app bundle + run: ./package-macos-app.sh bundle - name: Create DMG - run: hdiutil create -volname "Moonlight Installer" -srcfolder target/release/bundle/osx -ov -format UDZO moonlight-installer-macos.dmg + run: hdiutil create -volname "moonlight installer" -srcfolder temp/app -ov -format UDZO moonlight-installer-macos.dmg - name: Upload artifact uses: actions/upload-artifact@v4 with: diff --git a/.gitignore b/.gitignore index 048c68b..588e311 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target/ +temp/ .DS_Store \ No newline at end of file diff --git a/assets/Info.plist b/assets/Info.plist new file mode 100644 index 0000000..050841b --- /dev/null +++ b/assets/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDisplayName + moonlight installer + CFBundleExecutable + moonlight-installer + CFBundleIconFile + Icon.icns + CFBundleIdentifier + io.github.moonlight-mod.moonlight-installer + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + moonlight installer + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.2.0 + CFBundleVersion + 0.2.0 + CSResourcesFileMapped + + LSRequiresCarbon + + NSHighResolutionCapable + + + diff --git a/assets/icon.icns b/assets/icon.icns new file mode 100644 index 0000000..dddfbe5 Binary files /dev/null and b/assets/icon.icns differ diff --git a/package-macos-app.sh b/package-macos-app.sh new file mode 100755 index 0000000..c51557a --- /dev/null +++ b/package-macos-app.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +# Packaging script to build a macOS .app bundle +# If no arguments are passed, will build a single-architecture .app using the binary at +# ./target/release/moonlight-installer +# Specifying "bundle" will combine the binaries at +# ./target/x86_64-apple-darwin/release/moonlight-installer +# ./target/aarch64-apple-darwin/release/moonlight-installer + +APPNAME="moonlight installer.app" +EXENAME=moonlight-installer +ICON=assets/icon.icns +PLIST=assets/Info.plist + +# Clear the temp folders +rm -rf temp +if [[ "$1" == "clean" ]]; then + exit +fi + +# Make our temporary folders +mkdir -p temp/app + +if [[ "$1" == "bundle" ]]; then + EXECUTABLE=temp/$EXENAME + echo "Creating universal binary..." + lipo -create target/x86_64-apple-darwin/release/$EXENAME target/aarch64-apple-darwin/release/$EXENAME -output $EXECUTABLE +else + EXECUTABLE=target/release/$EXENAME +fi + +# Make the app directory structure +APPDIR="temp/app/$APPNAME" +echo "Building app bundle..." +mkdir -p "$APPDIR/Contents/MacOS" +mkdir -p "$APPDIR/Contents/Resources" +# Copy our assets to it +cp $PLIST "$APPDIR/Contents/Info.plist" +cp $ICON "$APPDIR/Contents/Resources/Icon.icns" +# Copy the merged binary +cp $EXECUTABLE "$APPDIR/Contents/MacOS/$EXENAME" + +# Apply an ad-hoc signature +echo "Code signing..." +codesign --force --deep -s - "$APPDIR" + +echo "Built '$APPDIR'"