mirror of
https://github.com/tobi/disktree.git
synced 2026-11-28 08:00:53 +00:00
macOS support: native Trash, APFS-aware scans, a signed app bundle
disktree built and drew on macOS already, through GPUI's Metal backend, but the Linux plumbing underneath did not carry over. This makes it work well there, without unsafe code, and tightens removal safety for every platform on the way. Trash and removal - On macOS always the system Trash, through NSFileManager (the trash crate): the same move as Finder's, into the item's own disk's Trash. gio/trash-put/XDG would put files in ~/.local/share/Trash, which Finder never shows. - Refuse a directory holding the home directory (/Users is on the same volume as / on macOS) or a system tree (/opt holds /opt/homebrew); add /System, /Library, /private, /opt/homebrew, /cores, /Network. - Refuse a directory with a mount inside it; on macOS the mount list comes from /sbin/mount, read on a background thread. - Permanent deletion walks the tree itself and stops at a mount boundary, like rm -rf --one-file-system (the walker is from #10). - Guards see through /System/Volumes/Data spellings and, on macOS, case. Scanning - Skip /System/Volumes/Data when scanning /: it is /Users, /Applications and the rest again under firmlinks, so / was counted twice. - Whole disk (g, --disk) works: the disk root and device come from statfs. - Never list cloud-only (dataless) iCloud/File Provider folders, which would download them. - Keep a file's identity only when it has more than one name. App - Explain unreadable items when Full Disk Access is missing, with a button to the privacy settings. - A menu bar: Open Folder… (⌘O), Show in Finder (o, ⌘⇧R), Rescan (⌘R), Hide, Quit; closing the window quits; other ⌘ chords are not read as plain letters; help shows ⌘. - Follow the system light/dark appearance when no Omarchy theme exists. - Worth a look knows Xcode DerivedData, DeviceSupport and ~/Library/Logs. - git: skipped without the developer tools (its stub opens a dialog), and never runs a checkout's programs: fsmonitor, hooks and pager off, and no status for a checkout that defines its own filter drivers. Packaging - cargo xtask bundle builds disktree.app and a zip: Info.plist (bundle id io.github.tobi.disktree, macOS 11+), an icon drawn from an SVG on the macOS grid, ad-hoc or Developer ID signing, and --notarize. - make install on macOS puts the app in ~/Applications and links ~/.local/bin/disktree to it. - CI lints, tests and bundles on macOS; the release adds an arm64 macOS zip, signed and notarized when the repository has the Apple secrets.
This commit is contained in:
@@ -43,3 +43,30 @@ jobs:
|
||||
|
||||
- name: Test
|
||||
run: cargo xtask test
|
||||
|
||||
check-macos:
|
||||
name: Lint and test (macOS)
|
||||
# Apple silicon. No system libraries to install, and no Metal toolchain
|
||||
# either: gpui-kit builds GPUI with runtime shader compilation, so the
|
||||
# shaders compile when the app starts, not here.
|
||||
runs-on: macos-15
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: "1.97"
|
||||
components: clippy, rustfmt
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Lint
|
||||
run: cargo xtask lint
|
||||
|
||||
- name: Test
|
||||
run: cargo xtask test
|
||||
|
||||
# The app bundle, signed ad hoc: catches a broken Info.plist, icon or
|
||||
# signature before a release does.
|
||||
- name: Bundle
|
||||
run: cargo xtask bundle
|
||||
|
||||
@@ -86,3 +86,92 @@ jobs:
|
||||
gh release create "$TAG" "$ARCHIVE" "$ARCHIVE.sha256" \
|
||||
--title "disktree ${TAG#v}" --generate-notes
|
||||
fi
|
||||
|
||||
release-macos:
|
||||
name: Build and publish (macOS)
|
||||
# After the Linux job, which creates the release: two jobs racing to
|
||||
# create it would leave one failing.
|
||||
needs: release
|
||||
runs-on: macos-15
|
||||
env:
|
||||
# Signing and notarizing happen only when the repository has these
|
||||
# secrets; without them the app is signed ad hoc, and a downloaded
|
||||
# copy needs "Open Anyway" in System Settings once.
|
||||
# MACOS_CERTIFICATE base64 of the Developer ID .p12
|
||||
# MACOS_CERTIFICATE_PASSWORD its password
|
||||
# MACOS_SIGN_IDENTITY "Developer ID Application: Name (TEAMID)"
|
||||
# NOTARY_KEY_P8 base64 of an App Store Connect API key
|
||||
# NOTARY_KEY_ID, NOTARY_ISSUER that key's ID and issuer
|
||||
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
|
||||
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
|
||||
MACOS_SIGN_IDENTITY: ${{ secrets.MACOS_SIGN_IDENTITY }}
|
||||
NOTARY_KEY_P8: ${{ secrets.NOTARY_KEY_P8 }}
|
||||
NOTARY_KEY_ID: ${{ secrets.NOTARY_KEY_ID }}
|
||||
NOTARY_ISSUER: ${{ secrets.NOTARY_ISSUER }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{ inputs.tag || github.ref }}
|
||||
|
||||
- name: Version
|
||||
id: version
|
||||
run: |
|
||||
tag="${{ inputs.tag || github.ref_name }}"
|
||||
version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
|
||||
if [ "$tag" != "v$version" ]; then
|
||||
echo "tag $tag does not match Cargo.toml version $version" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
||||
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: "1.97"
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Test
|
||||
run: cargo xtask test
|
||||
|
||||
# A keychain of its own for the certificate, deleted with the runner.
|
||||
- name: Signing certificate
|
||||
if: env.MACOS_CERTIFICATE != ''
|
||||
run: |
|
||||
keychain="$RUNNER_TEMP/signing.keychain-db"
|
||||
password=$(uuidgen)
|
||||
echo "$MACOS_CERTIFICATE" | base64 --decode > "$RUNNER_TEMP/cert.p12"
|
||||
security create-keychain -p "$password" "$keychain"
|
||||
security set-keychain-settings -lut 3600 "$keychain"
|
||||
security unlock-keychain -p "$password" "$keychain"
|
||||
security import "$RUNNER_TEMP/cert.p12" -k "$keychain" \
|
||||
-P "$MACOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
|
||||
security set-key-partition-list -S apple-tool:,apple: \
|
||||
-s -k "$password" "$keychain"
|
||||
security list-keychains -d user -s "$keychain" \
|
||||
$(security list-keychains -d user | tr -d '"')
|
||||
rm "$RUNNER_TEMP/cert.p12"
|
||||
|
||||
- name: Bundle
|
||||
run: |
|
||||
args=()
|
||||
if [ -n "$MACOS_CERTIFICATE" ]; then
|
||||
args+=(--sign "$MACOS_SIGN_IDENTITY")
|
||||
if [ -n "$NOTARY_KEY_P8" ]; then
|
||||
echo "$NOTARY_KEY_P8" | base64 --decode \
|
||||
> "$RUNNER_TEMP/AuthKey.p8"
|
||||
export NOTARY_KEY="$RUNNER_TEMP/AuthKey.p8"
|
||||
args+=(--notarize)
|
||||
fi
|
||||
fi
|
||||
cargo xtask bundle "${args[@]}"
|
||||
|
||||
- name: Publish
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ steps.version.outputs.tag }}
|
||||
run: |
|
||||
zip="target/bundle/disktree-${{ steps.version.outputs.version }}-aarch64-macos.zip"
|
||||
(cd "$(dirname "$zip")" && shasum -a 256 "$(basename "$zip")" \
|
||||
> "$(basename "$zip").sha256")
|
||||
gh release upload "$TAG" "$zip" "$zip.sha256" --clobber
|
||||
|
||||
Reference in New Issue
Block a user