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
18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,25 @@ jobs:
- name: Build macOS
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: |
tar -C build/macos/Build/Products -czf wimsy-macos.tar.gz Release
set -euo pipefail
# Only tag builds have a version Flutter passes through unchanged:
# pre-release versions like 0.0.6-pre-<sha> 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:
name: wimsy-macos
path: wimsy-macos.tar.gz
path: wimsy-macos.dmg

build-ios:
needs: analyze
Expand Down Expand Up @@ -735,7 +747,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
Expand Down
44 changes: 44 additions & 0 deletions tool/package_macos_dmg.sh
Original file line number Diff line number Diff line change
@@ -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"
108 changes: 108 additions & 0 deletions tool/verify_macos_dmg.sh
Original file line number Diff line number Diff line change
@@ -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"
Loading