diff --git a/.gitignore b/.gitignore index 7ef3b1d..b9f5e4f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,10 @@ ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +# MacOS Finder files +*.DS_Store +.DS_Store? + # User-specific files *.rsuser *.suo diff --git a/macbuild/README.md b/macbuild/README.md new file mode 100644 index 0000000..f39905d --- /dev/null +++ b/macbuild/README.md @@ -0,0 +1,8 @@ +This script builds the app, codesigns it, notarizes it, packages it into a disk image for intuitive installation, and notarizes that dmg. + +To properly build and codesign for MacOS, this script needs to be run by someone with an Apple Developer Program account. +As this costs $99 a year to obtain, builds are currently made by @gdmagana. +The Stardrop.csproj also must be replaced in the original project so that both architectures can be targeted. + +usage: +`./build-mac --arch osx-arm64` (leave blank to build both) diff --git a/macbuild/Stardrop.csproj b/macbuild/Stardrop.csproj new file mode 100644 index 0000000..2e77ecd --- /dev/null +++ b/macbuild/Stardrop.csproj @@ -0,0 +1,180 @@ + + + WinExe + net7.0 + enable + 1.2.1 + false + true + Assets\icon.ico + osx-x64;osx-arm64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FlexibleOptionWindow.axaml + + + NexusInfo.axaml + + + ProfileNaming.axaml + + + ProfileEditor.axaml + + + WarningWindow.axaml + + + DownloadPanel.axaml + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macbuild/assets/background.png b/macbuild/assets/background.png new file mode 100644 index 0000000..bbdf116 Binary files /dev/null and b/macbuild/assets/background.png differ diff --git a/macbuild/assets/ents.entitlements b/macbuild/assets/ents.entitlements new file mode 100644 index 0000000..7a872ea --- /dev/null +++ b/macbuild/assets/ents.entitlements @@ -0,0 +1,14 @@ + + + + + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.disable-library-validation + + com.apple.security.automation.apple-events + + + \ No newline at end of file diff --git a/macbuild/build-mac.sh b/macbuild/build-mac.sh new file mode 100755 index 0000000..b05e768 --- /dev/null +++ b/macbuild/build-mac.sh @@ -0,0 +1,130 @@ +#!/bin/bash + +APP_NAME="Stardrop" +HOME="/Users/gdmagana" +PROJECT_DIR="$HOME/Developer/Github/Stardrop/Stardrop" +OUTPUT_DIR="$HOME/Developer/Github/Stardrop/releases" +ASSETS_DIR="$PROJECT_DIR/Assets" +MAC_ASSETS_DIR="assets" +ENTITLEMENTS="$MAC_ASSETS_DIR/ents.entitlements" +SIGNING_IDENTITY="Developer ID Application: Gabriel Magaña (Z4D7MUNZ97)" +DMG_BACKGROUND="$MAC_ASSETS_DIR/background.png" + +# Architectures to build for +DEFAULT_ARCHS=("osx-x64" "osx-arm64") +ARCHS=() + +# Parse command line arguments +while [[ $# -gt 0 ]]; do + case $1 in + --arch) + if [[ -z "$2" || "$2" == --* ]]; then + echo "Error: --arch requires an architecture value" + exit 1 + fi + ARCHS+=("$2") + shift 2 + ;; + --arch=*) + arch_value="${1#*=}" + if [[ -z "$arch_value" ]]; then + echo "Error: --arch= requires an architecture value" + exit 1 + fi + ARCHS+=("$arch_value") + shift + ;; + -h|--help) + echo "Usage: $0 [--arch architecture]" + echo " --arch architecture Build for specific architecture (can be specified multiple times)" + echo " Default: osx-x64 osx-arm64" + exit 0 + ;; + *) + echo "Unknown parameter: $1" + echo "Use --help for usage information" + exit 1 + ;; + esac +done + +# If no architectures specified, use defaults +if [ ${#ARCHS[@]} -eq 0 ]; then + ARCHS=("${DEFAULT_ARCHS[@]}") +fi + +# Ensure output directory exists +mkdir -p "$OUTPUT_DIR" + +for ARCH in "${ARCHS[@]}"; do + echo "[INFO] Building for $ARCH..." + mkdir -p "$OUTPUT_DIR/$ARCH" + + # Step 1: Build the project + # dotnet publish "$PROJECT_DIR/Stardrop.csproj" -c Release -r $ARCH --self-contained || exit 1 + dotnet publish "$PROJECT_DIR/Stardrop.csproj" -r $ARCH -c Release /p:PublishSingleFile=true \ + /p:IncludeAllContentForSelfExtract=true /p:IncludeNativeLibrariesForSelfExtract=true \ + /p:EnableCompressionInSingleFile=true /p:PublishReadyToRun=true \ + -p:UseAppHost=true --self-contained true || exit 1 + # Check if the build was successful + if [ $? -ne 0 ]; then + echo "[ERROR] Build failed for $ARCH" + exit 1 + fi + echo "[INFO] Build successful for $ARCH" + + # Step 2: Create the .app bundle + BUILD_DIR="$PROJECT_DIR/bin/Release/$ARCH/publish" + APP_BUNDLE="$OUTPUT_DIR/$ARCH/$APP_NAME.app" + rm -rf "$APP_BUNDLE" + mkdir -p "$APP_BUNDLE/Contents/MacOS" + mkdir -p "$APP_BUNDLE/Contents/Resources" + + # Copy executable and resources + cp "$BUILD_DIR/$APP_NAME" "$APP_BUNDLE/Contents/MacOS/" + cp "$BUILD_DIR/"*.dylib "$APP_BUNDLE/Contents/MacOS/" + cp -R "$BUILD_DIR/Themes" "$APP_BUNDLE/Contents/MacOS/" + cp -R "$BUILD_DIR/i18n" "$APP_BUNDLE/Contents/MacOS/" + cp "$ASSETS_DIR/Info.plist" "$APP_BUNDLE/Contents/" + cp "$ASSETS_DIR/Stardrop.icns" "$APP_BUNDLE/Contents/Resources/" + + # Step 3: Sign the .app bundle + echo "[INFO] Signing the .app bundle for $ARCH..." + find "$APP_BUNDLE/Contents/MacOS" -type f | while read -r fname; do + codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign "$SIGNING_IDENTITY" "$fname" + done + codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign "$SIGNING_IDENTITY" "$APP_BUNDLE" + + # Step 4: Notarize the .app bundle + echo "[INFO] Notarizing the .app bundle for $ARCH..." + ZIP_FILE="$OUTPUT_DIR/$ARCH/$APP_NAME.zip" + ditto -c -k --sequesterRsrc --keepParent "$APP_BUNDLE" "$ZIP_FILE" + xcrun notarytool submit "$ZIP_FILE" --wait --keychain-profile Stardrop || exit 1 + xcrun stapler staple "$APP_BUNDLE" + # Cleanup + rm "$ZIP_FILE" + + # Step 5: Create a DMG file + echo "[INFO] Creating a DMG file for $ARCH..." + DMG_FILE="$OUTPUT_DIR/$ARCH/$APP_NAME.dmg" + # Clean up any old temporary DMG files + rm -f "$OUTPUT_DIR"/"$ARCH"/rw.*.dmg + create-dmg \ + --icon-size 128 \ + --volname "$APP_NAME" \ + --text-size 16 \ + --icon "$APP_NAME.app" 200 150 \ + --app-drop-link 450 150 \ + --window-pos 200 200 \ + --window-size 650 376 \ + --background "$DMG_BACKGROUND" \ + --disk-image-size 150 \ + "$DMG_FILE" "$OUTPUT_DIR/$ARCH" \ + + # Step 6: Notarize the DMG file + echo "[INFO] Notarizing the DMG file for $ARCH..." + xcrun notarytool submit "$DMG_FILE" --wait --keychain-profile Stardrop || exit 1 + xcrun stapler staple "$DMG_FILE" +done + +echo "[INFO] Build and packaging complete. Output: $OUTPUT_DIR"