From 1197ec9518eb4b37d6e9adcc18f11ad00dc59755 Mon Sep 17 00:00:00 2001 From: Dan Caseley Date: Wed, 18 Nov 2026 10:57:06 +0000 Subject: [PATCH 1/2] Package macOS release as a DMG containing only wimsy.app The macOS release asset was a tarball of the entire Xcode build/macos/Build/Products/Release directory: ~1.3 GB unpacked (396 MB compressed) of .o files, .swiftmodule directories, SwiftPM resource bundles, duplicate frameworks and ~860 MB of dSYMs, with wimsy.app buried inside. Add tool/package_macos_dmg.sh, which stages only the app bundle (copied with ditto to preserve framework symlinks, permissions and the code signature) alongside an /Applications symlink for drag-to-install, builds a compressed UDZO DMG, and runs hdiutil verify on it. CI now runs this script and uploads/publishes wimsy-macos.dmg instead of wimsy-macos.tar.gz. The script deliberately does no signing: once Developer ID signing is added, the app is signed before this step and the DMG is notarized/stapled after it, with no change needed here. dSYMs are no longer shipped to users. Testing: - Ran the script against the v0.0.6 release wimsy.app: produced a 60 MB DMG (vs the 396 MB tarball) that passes hdiutil verify; mounted, it contains only wimsy.app and the Applications symlink; codesign --verify --deep --strict passes on the app inside and all 18 framework symlinks are intact. - Script exits 1 with a clear error when the app bundle is missing. - A local `flutter build macos --release` could not be used for an end-to-end check: Xcode refuses to build the Runner target because its keychain-access-groups entitlement requires a development certificate. That is a separate, pre-existing issue. - flutter analyze: no issues. flutter test: all 1044 passed. vendor/xmpp_stone dart test: all 190 passed. - Maestro flows not run: no Android emulator available, and this change touches only CI packaging, not the app. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 7 +++---- tool/package_macos_dmg.sh | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) create mode 100755 tool/package_macos_dmg.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78b6bf1e..653a8f66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -405,13 +405,12 @@ jobs: - name: Build macOS run: flutter build macos --release - name: Package macOS - run: | - tar -C build/macos/Build/Products -czf wimsy-macos.tar.gz Release + run: tool/package_macos_dmg.sh build/macos/Build/Products/Release/wimsy.app wimsy-macos.dmg - name: Upload macOS artifact uses: actions/upload-artifact@v6 with: name: wimsy-macos - path: wimsy-macos.tar.gz + path: wimsy-macos.dmg build-ios: needs: analyze @@ -735,7 +734,7 @@ jobs: dist/wimsy-linux-deb/wimsy_*.deb dist/wimsy-windows/wimsy-windows.zip dist/wimsy-windows-msix/*.msix - dist/wimsy-macos/wimsy-macos.tar.gz + dist/wimsy-macos/wimsy-macos.dmg dist/wimsy-android/app-release.apk dist/wimsy-web/wimsy-web.tar.gz dist/sbom-linux/sbom-linux.cdx.json diff --git a/tool/package_macos_dmg.sh b/tool/package_macos_dmg.sh new file mode 100755 index 00000000..947d3710 --- /dev/null +++ b/tool/package_macos_dmg.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# Packages a built macOS app bundle into a compressed, drag-to-install DMG. +# +# Usage: tool/package_macos_dmg.sh [APP_PATH] [OUTPUT_DMG] +# APP_PATH defaults to build/macos/Build/Products/Release/wimsy.app +# OUTPUT_DMG defaults to wimsy-macos.dmg +# +# The DMG contains only the .app and an /Applications symlink, so users can +# drag the app across to install it. Build intermediates and dSYMs from the +# Xcode products directory are deliberately excluded. +# +# Signing is out of scope here: the app should already be signed before this +# runs, and a notarized release would sign/notarize/staple the resulting DMG +# afterwards. +set -euo pipefail + +app_path="${1:-build/macos/Build/Products/Release/wimsy.app}" +output_dmg="${2:-wimsy-macos.dmg}" +volume_name="Wimsy" + +if [[ ! -d "$app_path" ]]; then + echo "error: app bundle not found at $app_path" >&2 + exit 1 +fi + +staging_dir="$(mktemp -d)" +trap 'rm -rf "$staging_dir"' EXIT + +# ditto preserves framework symlinks, permissions, extended attributes and +# the code signature exactly. +ditto "$app_path" "$staging_dir/$(basename "$app_path")" +ln -s /Applications "$staging_dir/Applications" + +rm -f "$output_dmg" +hdiutil create \ + -volname "$volume_name" \ + -srcfolder "$staging_dir" \ + -fs HFS+ \ + -format UDZO \ + -ov \ + "$output_dmg" + +hdiutil verify "$output_dmg" +echo "Created $output_dmg" From d217e1d68a68585089e849699452ddd11dd2c67e Mon Sep 17 00:00:00 2001 From: Dan Caseley Date: Wed, 18 Nov 2026 11:09:21 +0000 Subject: [PATCH 2/2] Verify the macOS DMG in CI before uploading it Add tool/verify_macos_dmg.sh and run it in the build-macos job between packaging and upload. It mounts the DMG read-only at a private mount point (always detached on exit) and checks that: - the image passes hdiutil verify and mounts; - the volume contains exactly wimsy.app and an Applications symlink pointing at /Applications; - wimsy.app passes codesign --verify --deep --strict; - the main executable is universal (x86_64 and arm64); - CFBundleShortVersionString equals the expected version, when one is given. All failures are reported before exiting non-zero. CI passes the expected version only for v* tag builds. Flutter strips every non-digit/non-dot character from the build name on Apple platforms, so a pre-release version such as 0.0.6-pre-1197ec9 becomes 0.0.611979 in the bundle and cannot be compared. These checks pass for the current ad-hoc signed build and remain valid once Developer ID signing is added. Checks specific to that signing (authority, hardened runtime, spctl, stapler) are left for the change that introduces it. Testing: - Against the DMG built from the v0.0.6 wimsy.app: passes with no expected version and with 0.0.6. - Negative cases, each exits 1 with a specific FAIL line: expected version 0.0.7; a tampered App.framework inside the app (codesign failure); an extra file on the volume plus an arm64-only app (both reported); a truncated DMG (verify and mount failures, remaining checks skipped); a missing DMG path. - No images left mounted after any case. - shellcheck clean on both tool/*.sh scripts; workflow YAML parses with the new step between "Package macOS" and "Upload macOS artifact". - flutter analyze: no issues. flutter test: all 1044 passed. vendor/xmpp_stone dart test: all 190 passed. - Maestro flows not run: no Android emulator available, and this change touches only CI packaging, not the app. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 13 +++++ tool/verify_macos_dmg.sh | 108 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100755 tool/verify_macos_dmg.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 653a8f66..b8f6d36a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -406,6 +406,19 @@ jobs: run: flutter build macos --release - name: Package macOS run: tool/package_macos_dmg.sh build/macos/Build/Products/Release/wimsy.app wimsy-macos.dmg + - name: Verify macOS package + shell: bash + run: | + set -euo pipefail + # Only tag builds have a version Flutter passes through unchanged: + # pre-release versions like 0.0.6-pre- are mangled into + # CFBundleShortVersionString (non-digits stripped), so skip the + # version check for those. + expected_version="" + if [[ "${GITHUB_REF:-}" == refs/tags/v* ]]; then + expected_version="${GITHUB_REF#refs/tags/v}" + fi + tool/verify_macos_dmg.sh wimsy-macos.dmg "$expected_version" - name: Upload macOS artifact uses: actions/upload-artifact@v6 with: diff --git a/tool/verify_macos_dmg.sh b/tool/verify_macos_dmg.sh new file mode 100755 index 00000000..37ff2348 --- /dev/null +++ b/tool/verify_macos_dmg.sh @@ -0,0 +1,108 @@ +#!/usr/bin/env bash +# Verifies a macOS release DMG produced by tool/package_macos_dmg.sh. +# +# Usage: tool/verify_macos_dmg.sh DMG_PATH [EXPECTED_VERSION] +# DMG_PATH the DMG to check +# EXPECTED_VERSION optional; if given, wimsy.app's CFBundleShortVersionString +# must equal it exactly +# +# Checks (all must pass; every failure is reported before exiting non-zero): +# - the image passes hdiutil verify and mounts read-only +# - the volume contains exactly wimsy.app and an Applications -> /Applications +# symlink (hidden volume metadata such as .fseventsd is ignored) +# - wimsy.app passes codesign --verify --deep --strict +# - the main executable is universal (x86_64 and arm64) +# - the bundle version matches EXPECTED_VERSION, when given +# +# These checks hold for both the current ad-hoc signed build and a future +# Developer ID signed and notarized build. Checks specific to Developer ID +# signing and notarization (signing authority, hardened runtime, spctl, +# stapler) belong with the change that introduces that signing. +set -euo pipefail + +dmg_path="${1:?usage: $0 DMG_PATH [EXPECTED_VERSION]}" +expected_version="${2:-}" +app_name="wimsy.app" + +failures=0 +fail() { + echo "FAIL: $*" >&2 + failures=$((failures + 1)) +} +pass() { + echo "ok: $*" +} + +if [[ ! -f "$dmg_path" ]]; then + echo "error: DMG not found at $dmg_path" >&2 + exit 1 +fi + +if hdiutil verify -quiet "$dmg_path"; then + pass "hdiutil verify" +else + fail "hdiutil verify" +fi + +# Mount at a private mount point so a volume already mounted under +# /Volumes/Wimsy (e.g. on a developer machine) cannot interfere. +mount_point="$(mktemp -d)" +cleanup() { + hdiutil detach -quiet "$mount_point" 2>/dev/null || true + rmdir "$mount_point" 2>/dev/null || true +} +trap cleanup EXIT +if ! hdiutil attach -quiet -readonly -nobrowse -noautoopen \ + -mountpoint "$mount_point" "$dmg_path"; then + fail "could not mount $dmg_path; remaining checks skipped" + echo "$failures check(s) failed" >&2 + exit 1 +fi + +# Top-level contents, ignoring hidden volume metadata. +contents="$(cd "$mount_point" && find . -mindepth 1 -maxdepth 1 ! -name '.*' | sed 's|^\./||' | LC_ALL=C sort | tr '\n' ' ')" +if [[ "$contents" == "Applications $app_name " ]]; then + pass "volume contains only $app_name and Applications" +else + fail "unexpected volume contents: $contents" +fi + +if [[ -L "$mount_point/Applications" && "$(readlink "$mount_point/Applications")" == "/Applications" ]]; then + pass "Applications is a symlink to /Applications" +else + fail "Applications is not a symlink to /Applications" +fi + +app="$mount_point/$app_name" +if [[ ! -d "$app" ]]; then + fail "$app_name missing; skipping app checks" +else + if codesign --verify --deep --strict "$app"; then + pass "codesign --verify --deep --strict" + else + fail "codesign --verify --deep --strict" + fi + + executable="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "$app/Contents/Info.plist")" + archs="$(lipo -archs "$app/Contents/MacOS/$executable")" + if [[ " $archs " == *" x86_64 "* && " $archs " == *" arm64 "* ]]; then + pass "universal executable ($archs)" + else + fail "executable is not universal: $archs" + fi + + version="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$app/Contents/Info.plist")" + if [[ -z "$expected_version" ]]; then + echo "skip: version check (no expected version given; bundle has $version)" + elif [[ "$version" == "$expected_version" ]]; then + pass "bundle version $version" + else + fail "bundle version $version, expected $expected_version" + fi +fi + +if ((failures > 0)); then + echo "$failures check(s) failed" >&2 + exit 1 +fi +echo "All checks passed"