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
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ make run # build and run, scanning $HOME
make install # ~/.local: binary, desktop entry, icon
make install PREFIX=/usr/local # system-wide (needs root)
make uninstall
make bundle # macOS: target/bundle/disktree.app and its zip
make lint # rustfmt --check, then clippy --all-targets -D warnings
make test # core and window-harness tests
make ci # lint, then test
Expand All @@ -30,6 +31,11 @@ prefix and the crate version) and `assets/disktree.svg`. Keep the desktop
entry's `Categories` to a single main category plus additional ones, or
`desktop-file-validate` complains.

On macOS `make install` installs `target/bundle/disktree.app` into
`~/Applications` instead, built by `cargo xtask bundle` from
`packaging/macos/` (the `Info.plist` template and the icon's SVG). The bundle
identifier there keys every macOS permission grant; do not change it lightly.

`cargo xtask lint` is the gate. It must be green before anything is called
done, and it must not fix anything: a red local run is the same signal CI gives.

Expand Down
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 36 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,36 @@
#
# make install # ~/.local/bin/disktree
# sudo make install PREFIX=/usr/local # system-wide
#
# On macOS it installs disktree.app into ~/Applications instead (APPS to
# change that), plus a `disktree` command in BINDIR that runs the app's
# binary, so both Spotlight and a terminal find it.

PREFIX ?= $(HOME)/.local
BINDIR ?= $(PREFIX)/bin
APPDIR ?= $(PREFIX)/share/applications
ICONDIR ?= $(PREFIX)/share/icons/hicolor/scalable/apps

APPS ?= $(HOME)/Applications
BUNDLE = target/bundle/disktree.app
UNAME := $(shell uname -s)

MANIFEST = Cargo.toml
CARGO ?= cargo
TARGET = target/release/disktree
ICON = assets/disktree.svg
DESKTOP = packaging/disktree.desktop.in

.PHONY: help build run install uninstall lint test ci fmt clean
.PHONY: help build run install uninstall bundle lint test ci fmt clean

help:
@echo "disktree"
@echo
@echo " make build release build"
@echo " make run build and run, scanning $$HOME"
@echo " make install install to $(PREFIX): binary, desktop entry, icon"
@echo " (macOS: disktree.app into $(APPS))"
@echo " make bundle macOS: build target/bundle/disktree.app and its zip"
@echo " make uninstall remove what install put there"
@echo " make lint rustfmt --check and clippy -D warnings"
@echo " make test core and window-harness tests"
Expand Down Expand Up @@ -53,6 +63,27 @@ ci: lint test
fmt:
$(CARGO) xtask fmt-fix

ifeq ($(UNAME),Darwin)
# Replaced whole rather than copied over: a stale file left inside a signed
# bundle breaks its signature.
install:
$(CARGO) xtask bundle
install -d "$(APPS)" "$(BINDIR)"
rm -rf "$(APPS)/disktree.app"
ditto "$(BUNDLE)" "$(APPS)/disktree.app"
ln -sf "$(APPS)/disktree.app/Contents/MacOS/disktree" "$(BINDIR)/disktree"
@echo
@echo "installed:"
@echo " $(APPS)/disktree.app"
@echo " $(BINDIR)/disktree -> the app's binary"
@case ":$$PATH:" in *":$(BINDIR):"*) ;; *) \
echo; echo "note: $(BINDIR) is not on PATH in this shell";; esac

uninstall:
rm -rf "$(APPS)/disktree.app"
@if [ -L "$(BINDIR)/disktree" ]; then rm -f "$(BINDIR)/disktree"; fi
@echo "removed"
else
install: build
install -d $(BINDIR) $(APPDIR) $(ICONDIR)
install -m755 $(TARGET) $(BINDIR)/disktree
Expand Down Expand Up @@ -81,6 +112,10 @@ uninstall:
update-desktop-database $(APPDIR) 2>/dev/null || true; \
fi
@echo "removed"
endif

bundle:
$(CARGO) xtask bundle

clean:
$(CARGO) clean
Loading