From 26a8b1a295bafdb01a0c77f4d63f0ddbddc73198 Mon Sep 17 00:00:00 2001 From: Cryptokid92 <114345066+Cryptokid92@users.noreply.github.com> Date: Sun, 30 Aug 2026 12:47:35 +0200 Subject: [PATCH 1/2] feat(macutil): ship a drag-to-Applications DMG Universal MacUtil.app in an unsigned UDZO image with an Applications symlink. PublishTrimmed=false. macos-14 no longer waits on macos-13. --- .github/workflows/Release.yml | 1 + .github/workflows/macos-app.yml | 169 +++++++---------------- MacUtilGUI.Tests/MacUtilGUI.Tests.fsproj | 1 + MacUtilGUI.Tests/PackagingTests.fs | 68 +++++++++ README.md | 21 ++- scripts/make-dmg.sh | 107 ++++++++++++++ 6 files changed, 242 insertions(+), 125 deletions(-) create mode 100644 MacUtilGUI.Tests/PackagingTests.fs create mode 100644 scripts/make-dmg.sh diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 465466b..3c81ca6 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -43,6 +43,7 @@ jobs: ./artifacts/MacUtil-Universal.zip ./artifacts/MacUtil-macos-x64.zip ./artifacts/MacUtil-macos-arm64.zip + ./artifacts/MacUtil-${{ steps.version.outputs.version }}.dmg prerelease: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/macos-app.yml b/.github/workflows/macos-app.yml index 8f29319..d27f46c 100644 --- a/.github/workflows/macos-app.yml +++ b/.github/workflows/macos-app.yml @@ -9,6 +9,7 @@ on: - "MacUtilGUI/**" - "config/**" - "scripts/check-version.sh" + - "scripts/make-dmg.sh" - ".github/workflows/macos-app.yml" - ".github/workflows/Release.yml" pull_request: @@ -17,6 +18,7 @@ on: - "MacUtilGUI/**" - "config/**" - "scripts/check-version.sh" + - "scripts/make-dmg.sh" - ".github/workflows/macos-app.yml" - ".github/workflows/Release.yml" @@ -24,10 +26,10 @@ permissions: contents: read jobs: - macos-13: - name: macos-13 - runs-on: macos-13 - timeout-minutes: 30 + macos-14: + name: macos-14 + runs-on: macos-14 + timeout-minutes: 45 steps: - uses: actions/checkout@v5 @@ -41,57 +43,58 @@ jobs: with: path: ~/.nuget/packages key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} - restore-keys: ${{ runner.os }}-nuget- + restore-keys: | + ${{ runner.os }}-nuget- - name: Check version lock run: bash scripts/check-version.sh - - name: Publish osx-x64 - run: | - set -euo pipefail - dotnet publish MacUtilGUI/MacUtilGUI.fsproj \ - --configuration Release \ - --runtime osx-x64 \ - --self-contained true \ - --output ./build/osx-x64 \ - /p:PublishSingleFile=true \ - /p:IncludeNativeLibrariesForSelfExtract=true - file ./build/osx-x64/MacUtilGUI - lipo -info ./build/osx-x64/MacUtilGUI + - name: Build DMG + run: bash scripts/make-dmg.sh - - name: Smoke osx-x64 + - name: Smoke osx-arm64 run: | set -euo pipefail - chmod +x ./build/osx-x64/MacUtilGUI - ./build/osx-x64/MacUtilGUI > /tmp/macutil-smoke.log 2>&1 & + chmod +x ./dist/publish/osx-arm64/MacUtilGUI + ./dist/publish/osx-arm64/MacUtilGUI > /tmp/macutil-smoke.log 2>&1 & pid=$! sleep 8 if ! kill -0 "$pid" 2>/dev/null; then - echo "smoke failed: osx-x64 process died before 8s" >&2 + echo "smoke failed: osx-arm64 process died before 8s" >&2 cat /tmp/macutil-smoke.log >&2 || true exit 1 fi kill "$pid" 2>/dev/null || true wait "$pid" 2>/dev/null || true - echo "smoke ok: osx-x64 pid $pid stayed up 8s" + echo "smoke ok: osx-arm64 pid $pid stayed up 8s" - - name: Package Intel app + - name: Verify universal app and DMG run: | set -euo pipefail - bundle="./dist/MacUtil-Intel.app" - mkdir -p "$bundle/Contents/MacOS" "$bundle/Contents/Resources" - rsync -a ./build/osx-x64/ "$bundle/Contents/MacOS/" - chmod +x "$bundle/Contents/MacOS/MacUtilGUI" - cp MacUtilGUI/Info.plist "$bundle/Contents/Info.plist" - cp MacUtilGUI/MacUtilGUI.icns "$bundle/Contents/Resources/" - ditto -c -k --keepParent "$bundle" ./dist/MacUtil-macos-x64.zip - - - name: Upload osx-x64 binary - uses: actions/upload-artifact@v4 - with: - name: osx-x64 - path: ./build/osx-x64/MacUtilGUI - if-no-files-found: error + app="./dist/MacUtil.app" + test -d "$app" + test -f "$app/Contents/MacOS/config/tweaks.json" + chmod +x "$app/Contents/MacOS/MacUtilGUI" + lipo -info "$app/Contents/MacOS/MacUtilGUI" + lipo -info "$app/Contents/MacOS/MacUtilGUI" | grep x86_64 + lipo -info "$app/Contents/MacOS/MacUtilGUI" | grep arm64 + version=$(sed -n 's/.*\([^<]*\)<\/CFBundleVersion>.*/\1/p' MacUtilGUI/MacUtilGUI.fsproj | head -n 1) + dmg="./dist/MacUtil-${version}.dmg" + test -f "$dmg" + file "$dmg" + hdiutil imageinfo "$dmg" + if [ -e /Volumes/MacUtil ]; then + hdiutil detach /Volumes/MacUtil || true + fi + hdiutil attach -nobrowse "$dmg" + cleanup() { hdiutil detach /Volumes/MacUtil 2>/dev/null || true; } + trap cleanup EXIT + test -d /Volumes/MacUtil/MacUtil.app + test -L /Volumes/MacUtil/Applications + test "$(readlink /Volumes/MacUtil/Applications)" = "/Applications" + test -f /Volumes/MacUtil/MacUtil.app/Contents/MacOS/config/tweaks.json + hdiutil detach /Volumes/MacUtil + trap - EXIT - name: Upload Intel app uses: actions/upload-artifact@v4 @@ -100,91 +103,6 @@ jobs: path: ./dist/MacUtil-macos-x64.zip if-no-files-found: error - macos-14: - name: macos-14 - runs-on: macos-14 - timeout-minutes: 30 - needs: macos-13 - steps: - - uses: actions/checkout@v5 - - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: "9.0.x" - - - name: Cache .NET packages - uses: actions/cache@v4 - with: - path: ~/.nuget/packages - key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} - restore-keys: ${{ runner.os }}-nuget- - - - name: Check version lock - run: bash scripts/check-version.sh - - - name: Publish osx-arm64 - run: | - set -euo pipefail - dotnet publish MacUtilGUI/MacUtilGUI.fsproj \ - --configuration Release \ - --runtime osx-arm64 \ - --self-contained true \ - --output ./build/osx-arm64 \ - /p:PublishSingleFile=true \ - /p:IncludeNativeLibrariesForSelfExtract=true - file ./build/osx-arm64/MacUtilGUI - lipo -info ./build/osx-arm64/MacUtilGUI - - - name: Download osx-x64 binary - uses: actions/download-artifact@v4 - with: - name: osx-x64 - path: ./build/osx-x64 - - - name: Smoke osx-arm64 - run: | - set -euo pipefail - chmod +x ./build/osx-arm64/MacUtilGUI - ./build/osx-arm64/MacUtilGUI > /tmp/macutil-smoke.log 2>&1 & - pid=$! - sleep 8 - if ! kill -0 "$pid" 2>/dev/null; then - echo "smoke failed: osx-arm64 process died before 8s" >&2 - cat /tmp/macutil-smoke.log >&2 || true - exit 1 - fi - kill "$pid" 2>/dev/null || true - wait "$pid" 2>/dev/null || true - echo "smoke ok: osx-arm64 pid $pid stayed up 8s" - - - name: Lipo universal app - run: | - set -euo pipefail - chmod +x ./build/osx-x64/MacUtilGUI ./build/osx-arm64/MacUtilGUI - bundle="./dist/MacUtil-Universal.app" - mkdir -p "$bundle/Contents/MacOS" "$bundle/Contents/Resources" - rsync -a --exclude="MacUtilGUI" ./build/osx-arm64/ "$bundle/Contents/MacOS/" - lipo -create \ - ./build/osx-x64/MacUtilGUI \ - ./build/osx-arm64/MacUtilGUI \ - -output "$bundle/Contents/MacOS/MacUtilGUI" - chmod +x "$bundle/Contents/MacOS/MacUtilGUI" - cp MacUtilGUI/Info.plist "$bundle/Contents/Info.plist" - cp MacUtilGUI/MacUtilGUI.icns "$bundle/Contents/Resources/" - file "$bundle/Contents/MacOS/MacUtilGUI" - lipo -info "$bundle/Contents/MacOS/MacUtilGUI" - lipo -info "$bundle/Contents/MacOS/MacUtilGUI" | grep x86_64 - lipo -info "$bundle/Contents/MacOS/MacUtilGUI" | grep arm64 - arm_bundle="./dist/MacUtil-AppleSilicon.app" - mkdir -p "$arm_bundle/Contents/MacOS" "$arm_bundle/Contents/Resources" - rsync -a ./build/osx-arm64/ "$arm_bundle/Contents/MacOS/" - chmod +x "$arm_bundle/Contents/MacOS/MacUtilGUI" - cp MacUtilGUI/Info.plist "$arm_bundle/Contents/Info.plist" - cp MacUtilGUI/MacUtilGUI.icns "$arm_bundle/Contents/Resources/" - ditto -c -k --keepParent "$bundle" ./dist/MacUtil-Universal.zip - ditto -c -k --keepParent "$arm_bundle" ./dist/MacUtil-macos-arm64.zip - - name: Upload Apple Silicon app uses: actions/upload-artifact@v4 with: @@ -198,3 +116,10 @@ jobs: name: MacUtil-Universal path: ./dist/MacUtil-Universal.zip if-no-files-found: error + + - name: Upload DMG + uses: actions/upload-artifact@v4 + with: + name: MacUtil-dmg + path: ./dist/MacUtil-*.dmg + if-no-files-found: error diff --git a/MacUtilGUI.Tests/MacUtilGUI.Tests.fsproj b/MacUtilGUI.Tests/MacUtilGUI.Tests.fsproj index 522dca4..893c74b 100644 --- a/MacUtilGUI.Tests/MacUtilGUI.Tests.fsproj +++ b/MacUtilGUI.Tests/MacUtilGUI.Tests.fsproj @@ -19,6 +19,7 @@ + diff --git a/MacUtilGUI.Tests/PackagingTests.fs b/MacUtilGUI.Tests/PackagingTests.fs new file mode 100644 index 0000000..9c867fb --- /dev/null +++ b/MacUtilGUI.Tests/PackagingTests.fs @@ -0,0 +1,68 @@ +namespace MacUtilGUI.Tests + +open System +open System.IO +open Xunit + +module PackagingTests = + + let private repoRoot () = + let rec walk dir = + if String.IsNullOrEmpty dir then + None + elif + File.Exists(Path.Combine(dir, "scripts", "make-dmg.sh")) + || File.Exists(Path.Combine(dir, ".git")) + || Directory.Exists(Path.Combine(dir, ".git")) + then + Some dir + else + let parent = Directory.GetParent dir + + if isNull parent then None else walk parent.FullName + + match walk AppContext.BaseDirectory with + | Some dir -> dir + | None -> + match walk (Directory.GetCurrentDirectory()) with + | Some dir -> dir + | None -> failwith "repo root not found" + + let private read pathParts = + File.ReadAllText(Path.Combine(Array.append [| repoRoot () |] pathParts)) + + [] + let MakeDmgScript () = + let script = read [| "scripts"; "make-dmg.sh" |] + Assert.Contains("PublishTrimmed=false", script) + Assert.Contains("hdiutil", script) + Assert.Contains("Applications", script) + Assert.Contains("osx-x64", script) + Assert.Contains("osx-arm64", script) + Assert.Contains("lipo", script) + Assert.DoesNotContain("sudo", script) + Assert.DoesNotContain("/var/log", script) + + [] + let MacosAppWorkflow () = + let yml = read [| ".github"; "workflows"; "macos-app.yml" |] + Assert.DoesNotContain("needs: macos-13", yml) + Assert.Contains("scripts/make-dmg.sh", yml) + + [] + let ReleaseListsDmg () = + let yml = read [| ".github"; "workflows"; "Release.yml" |] + Assert.Contains(".dmg", yml) + + [] + let GitignoreIgnoresDist () = + let lines = + File.ReadAllLines(Path.Combine(repoRoot (), ".gitignore")) + |> Array.map (fun line -> line.Trim()) + |> Array.filter (fun line -> line.Length > 0 && not (line.StartsWith "#")) + + let ignored = + lines + |> Array.exists (fun line -> line = "/dist/" || line = "dist/" || line = "/dist" || line = "dist") + + Assert.True(ignored, ".gitignore must ignore repo-root dist/") diff --git a/README.md b/README.md index 35ac8e5..0969679 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,22 @@ Version is 0.2.1. Intel and Apple Silicon both build. ## Run it -You need .NET 9. Install, Maintenance, and Updates talk to Homebrew. +Download `MacUtil-.dmg` (currently `MacUtil-0.2.1.dmg`) from [GitHub Releases](https://github.com/Cryptokid92/macutil/releases). Open the disk image and drag `MacUtil.app` to Applications. + +The app is unsigned. First launch: right-click `MacUtil.app` and choose Open, or: + +```bash +xattr -cr /Applications/MacUtil.app +``` + +Local image (needs .NET 9): + +```bash +./scripts/make-dmg.sh +open dist/MacUtil-0.2.1.dmg +``` + +You can also run from source. Install, Maintenance, and Updates talk to Homebrew. ```bash git clone https://github.com/Cryptokid92/macutil.git @@ -56,8 +71,8 @@ dotnet test MacUtilGUI.Tests --configuration Release - Per-tab status. Export of ids uses `Utf8JsonWriter` so a trimmed GUI can still save a preset. - CLI. `dotnet run --project MacUtilCLI`. `detect` prints JSON of id to applied bool. `apply` and `undo` take `--preset`. `export` writes applied ids. `import` applies a JSON array of ids. - Opaque window. AcrylicBlur hid the window on Sequoia, so it is gone. -- Universal CI. macos-13 is set to publish `osx-x64`. macos-14 publishes `osx-arm64` and lipos a universal zip. Release no longer tries to emit Mach-O from Ubuntu. -- Tests. Schema, engine, tabs, presets, Maintenance, Updates, CLI, grouping, uninstall, and trim-safe export. Fake `defaults` and fake brew so CI does not write the runner's prefs. +- Universal CI. macos-14 publishes `osx-x64` and `osx-arm64`, lipos `MacUtil.app`, and wraps it in a drag-to-Applications DMG. `PublishTrimmed=false` on that publish so GUI Export keeps working. Release ships the DMG plus the three zip names. +- Tests. Schema, engine, tabs, presets, Maintenance, Updates, CLI, grouping, uninstall, trim-safe export, and packaging source checks. Fake `defaults` and fake brew so CI does not write the runner's prefs. Counts at this commit, regenerate with: diff --git a/scripts/make-dmg.sh b/scripts/make-dmg.sh new file mode 100644 index 0000000..2e7c766 --- /dev/null +++ b/scripts/make-dmg.sh @@ -0,0 +1,107 @@ +#!/usr/bin/env bash +set -euo pipefail + +root="$(cd "$(dirname "$0")/.." && pwd)" +cd "$root" + +fsproj="$root/MacUtilGUI/MacUtilGUI.fsproj" +version="$(sed -n 's/.*\([^<]*\)<\/CFBundleVersion>.*/\1/p' "$fsproj" | head -n 1)" + +if [ -z "$version" ]; then + echo "missing CFBundleVersion in $fsproj" >&2 + exit 1 +fi + +echo "version $version" + +plist="$root/MacUtilGUI/Info.plist" +icon="$root/MacUtilGUI/MacUtilGUI.icns" +app="$root/dist/MacUtil.app" +dmg="$root/dist/MacUtil-${version}.dmg" +x64_out="$root/dist/publish/osx-x64" +arm_out="$root/dist/publish/osx-arm64" + +stage="$(mktemp -d)" +intel_stage="$(mktemp -d)" +arm_stage="$(mktemp -d)" +trap 'rm -rf "$stage" "$intel_stage" "$arm_stage"' EXIT + +publish() { + local rid="$1" + local out="$2" + echo "publishing $rid" + rm -rf "$out" + mkdir -p "$out" + dotnet publish MacUtilGUI/MacUtilGUI.fsproj \ + --configuration Release \ + --runtime "$rid" \ + --self-contained true \ + --output "$out" \ + -p:UseAppHost=true \ + -p:PublishSingleFile=true \ + -p:IncludeNativeLibrariesForSelfExtract=true \ + -p:PublishTrimmed=false + mkdir -p "$out/config" + rsync -a "$root/config/" "$out/config/" + test -f "$out/MacUtilGUI" + test -f "$out/config/tweaks.json" +} + +bundle_app() { + local src="$1" + local dest="$2" + rm -rf "$dest" + mkdir -p "$dest/Contents/MacOS" "$dest/Contents/Resources" + rsync -a "$src/" "$dest/Contents/MacOS/" + chmod +x "$dest/Contents/MacOS/MacUtilGUI" + cp "$plist" "$dest/Contents/Info.plist" + cp "$icon" "$dest/Contents/Resources/MacUtilGUI.icns" + test -f "$dest/Contents/MacOS/config/tweaks.json" +} + +publish osx-x64 "$x64_out" +publish osx-arm64 "$arm_out" + +echo "bundling MacUtil.app" +rm -rf "$app" +mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" +rsync -a --exclude="MacUtilGUI" "$arm_out/" "$app/Contents/MacOS/" +lipo -create \ + "$x64_out/MacUtilGUI" \ + "$arm_out/MacUtilGUI" \ + -output "$app/Contents/MacOS/MacUtilGUI" +chmod +x "$app/Contents/MacOS/MacUtilGUI" +cp "$plist" "$app/Contents/Info.plist" +cp "$icon" "$app/Contents/Resources/MacUtilGUI.icns" +test -f "$app/Contents/MacOS/config/tweaks.json" + +lipo -info "$app/Contents/MacOS/MacUtilGUI" +lipo -info "$app/Contents/MacOS/MacUtilGUI" | grep x86_64 +lipo -info "$app/Contents/MacOS/MacUtilGUI" | grep arm64 + +if [ -e /Volumes/MacUtil ]; then + hdiutil detach /Volumes/MacUtil || true +fi + +ditto "$app" "$stage/MacUtil.app" +ln -s /Applications "$stage/Applications" + +echo "creating $dmg" +rm -f "$dmg" +hdiutil create -volname MacUtil -srcfolder "$stage" -ov -format UDZO "$dmg" + +bundle_app "$x64_out" "$intel_stage/MacUtil.app" +bundle_app "$arm_out" "$arm_stage/MacUtil.app" + +rm -f "$root/dist/MacUtil-Universal.zip" +rm -f "$root/dist/MacUtil-macos-x64.zip" +rm -f "$root/dist/MacUtil-macos-arm64.zip" +ditto -c -k --keepParent "$app" "$root/dist/MacUtil-Universal.zip" +ditto -c -k --keepParent "$intel_stage/MacUtil.app" "$root/dist/MacUtil-macos-x64.zip" +ditto -c -k --keepParent "$arm_stage/MacUtil.app" "$root/dist/MacUtil-macos-arm64.zip" + +echo "wrote $app" +echo "wrote $dmg" +echo "wrote $root/dist/MacUtil-Universal.zip" +echo "wrote $root/dist/MacUtil-macos-x64.zip" +echo "wrote $root/dist/MacUtil-macos-arm64.zip" From 7d5c0cfe19bfe571164faf69eb9b756aeb4e66bf Mon Sep 17 00:00:00 2001 From: Cryptokid92 <114345066+Cryptokid92@users.noreply.github.com> Date: Sun, 30 Aug 2026 12:48:45 +0200 Subject: [PATCH 2/2] chore(macutil): ignore repo-root dist/ for DMG output --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5bd3c8f..afb7486 100644 --- a/.gitignore +++ b/.gitignore @@ -322,6 +322,9 @@ MacUtilGUI/obj/ MacUtilGUI/dist/ MacUtilGUI/publish/ +# Repo-root DMG and publish output +/dist/ + # macOS specific files .DS_Store .DS_Store? @@ -329,4 +332,4 @@ MacUtilGUI/publish/ .Spotlight-V100 .Trashes ehthumbs.db -Thumbs.db \ No newline at end of file +Thumbs.db