Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
169 changes: 47 additions & 122 deletions .github/workflows/macos-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -17,17 +18,18 @@ on:
- "MacUtilGUI/**"
- "config/**"
- "scripts/check-version.sh"
- "scripts/make-dmg.sh"
- ".github/workflows/macos-app.yml"
- ".github/workflows/Release.yml"

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

Expand All @@ -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>\([^<]*\)<\/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
Expand All @@ -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:
Expand All @@ -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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,14 @@ MacUtilGUI/obj/
MacUtilGUI/dist/
MacUtilGUI/publish/

# Repo-root DMG and publish output
/dist/

# macOS specific files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
Thumbs.db
1 change: 1 addition & 0 deletions MacUtilGUI.Tests/MacUtilGUI.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<Compile Include="TweakTabTests.fs" />
<Compile Include="InstallTabTests.fs" />
<Compile Include="PresetTests.fs" />
<Compile Include="PackagingTests.fs" />
</ItemGroup>

<ItemGroup>
Expand Down
68 changes: 68 additions & 0 deletions MacUtilGUI.Tests/PackagingTests.fs
Original file line number Diff line number Diff line change
@@ -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))

[<Fact>]
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)

[<Fact>]
let MacosAppWorkflow () =
let yml = read [| ".github"; "workflows"; "macos-app.yml" |]
Assert.DoesNotContain("needs: macos-13", yml)
Assert.Contains("scripts/make-dmg.sh", yml)

[<Fact>]
let ReleaseListsDmg () =
let yml = read [| ".github"; "workflows"; "Release.yml" |]
Assert.Contains(".dmg", yml)

[<Fact>]
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/")
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<version>.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
Expand Down Expand Up @@ -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:

Expand Down
Loading
Loading