diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b70e379..773a701 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -104,8 +104,20 @@ jobs:
- name: Build
shell: bash
run: cargo build --release --locked --target ${{ matrix.target }}
- - name: Package (Unix)
- if: runner.os != 'Windows'
+ - name: Package (macOS app)
+ if: runner.os == 'macOS'
+ shell: bash
+ run: |
+ set -euo pipefail
+ app="$RUNNER_TEMP/Android CLI GUI.app"
+ packaging/macos/make-app.sh \
+ "target/${{ matrix.target }}/release/android-cli-gui" \
+ "$VERSION" "$app"
+ mkdir -p dist
+ ditto -c -k --sequesterRsrc --keepParent "$app" \
+ "dist/android-cli-gui-v${VERSION}-${{ matrix.artifact }}.zip"
+ - name: Package (Linux)
+ if: runner.os == 'Linux'
shell: bash
run: |
set -euo pipefail
@@ -161,12 +173,12 @@ jobs:
steps:
- uses: actions/checkout@v7
with:
- ref: ${{ needs.get-tag.outputs.commit }}
+ ref: ${{ github.event.repository.default_branch }}
- uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- - name: Render formula
+ - name: Render cask
shell: bash
env:
VERSION: ${{ needs.get-tag.outputs.version }}
@@ -179,13 +191,13 @@ jobs:
sed \
-e "s/__VERSION__/${VERSION}/g" \
- -e "s/__SHA256_MACOS_ARM64__/$(sha "android-cli-gui-v${VERSION}-aarch64-apple-darwin.tar.gz")/g" \
- -e "s/__SHA256_MACOS_X86_64__/$(sha "android-cli-gui-v${VERSION}-x86_64-apple-darwin.tar.gz")/g" \
- packaging/homebrew/android-cli-gui.rb.tmpl \
+ -e "s/__SHA256_MACOS_ARM64__/$(sha "android-cli-gui-v${VERSION}-macos-arm64.zip")/g" \
+ -e "s/__SHA256_MACOS_X86_64__/$(sha "android-cli-gui-v${VERSION}-macos-x86_64.zip")/g" \
+ packaging/homebrew/android-cli-gui.cask.rb.tmpl \
> dist/android-cli-gui.rb
ruby -c dist/android-cli-gui.rb
- - name: Push formula to tap
+ - name: Push cask to tap
shell: bash
env:
TAG: ${{ needs.get-tag.outputs.tag }}
@@ -202,16 +214,19 @@ jobs:
rm -rf tap
git clone --depth 1 git@github.com:RayhanHamada/homebrew-tap.git tap
- mkdir -p tap/Formula
- cp dist/android-cli-gui.rb tap/Formula/android-cli-gui.rb
+ mkdir -p tap/Casks
+ cp dist/android-cli-gui.rb tap/Casks/android-cli-gui.rb
+ if [[ -f tap/Formula/android-cli-gui.rb ]]; then
+ git -C tap rm Formula/android-cli-gui.rb
+ fi
git -C tap config user.name "github-actions[bot]"
git -C tap config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- git -C tap add Formula/android-cli-gui.rb
+ git -C tap add Casks/android-cli-gui.rb
if git -C tap diff --cached --quiet; then
- echo "Formula is already up to date."
+ echo "Cask is already up to date."
else
- git -C tap commit -m "android-cli-gui ${TAG}"
+ git -C tap commit -m "android-cli-gui ${TAG} (cask)"
git -C tap push origin HEAD:main
fi
diff --git a/README.md b/README.md
index 107fbd0..e3f6eba 100644
--- a/README.md
+++ b/README.md
@@ -8,16 +8,31 @@ comes from the official Android CLI and Android SDK sources.
## Install
-Homebrew (macOS 15+):
+Homebrew cask (macOS 15+):
```sh
-brew install RayhanHamada/tap/android-cli-gui
+brew tap RayhanHamada/tap
+brew trust --cask RayhanHamada/tap/android-cli-gui
+brew install --cask RayhanHamada/tap/android-cli-gui
```
-Prebuilt binaries for Linux, macOS (Apple Silicon and Intel), and Windows are on the
-[releases page](https://github.com/RayhanHamada/android-cli-gui/releases).
+This installs `Android CLI GUI.app` in `/Applications` and the official
+[`android-cli`](https://developer.android.com/tools/agents/android-cli) cask as
+a dependency. Launch it from Applications, Launchpad, or Spotlight like any
+other Mac app.
+
+Homebrew 7 requires trusting third-party casks before installation. On older
+Homebrew versions the `brew trust` step can be skipped.
+
+If you installed the old formula, remove it before switching:
-The official `android` CLI must be installed and available on `PATH`.
+```sh
+brew uninstall android-cli-gui
+```
+
+Prebuilt applications for macOS (Apple Silicon and Intel), binaries for Linux
+and Windows, and checksums are on the
+[releases page](https://github.com/RayhanHamada/android-cli-gui/releases).
## Build from source
@@ -27,9 +42,20 @@ Requires Rust stable and the [GPUI platform dependencies](https://gpui-kit.com/d
cargo run --release
```
+To build a macOS app bundle:
+
+```sh
+cargo build --release
+version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml)"
+packaging/macos/make-app.sh target/release/android-cli-gui "$version" \
+ "target/Android CLI GUI.app"
+open "target/Android CLI GUI.app"
+```
+
## Releases
Releases are managed by [Knope Bot](https://knope.tech/tutorials/bot-workflow/).
Install the bot for this repository; it keeps a `knope/release` PR up to date.
Merging that PR creates a draft GitHub release, and the Release workflow builds
-the binaries, uploads them, publishes the release, and updates the Homebrew tap.
+the packages, uploads them, publishes the release, and updates the Homebrew
+cask in the tap.
diff --git a/packaging/homebrew/android-cli-gui.cask.rb.tmpl b/packaging/homebrew/android-cli-gui.cask.rb.tmpl
new file mode 100644
index 0000000..10bc8dc
--- /dev/null
+++ b/packaging/homebrew/android-cli-gui.cask.rb.tmpl
@@ -0,0 +1,27 @@
+cask "android-cli-gui" do
+ arch arm: "macos-arm64", intel: "macos-x86_64"
+
+ version "__VERSION__"
+ sha256 arm: "__SHA256_MACOS_ARM64__",
+ intel: "__SHA256_MACOS_X86_64__"
+
+ url "https://github.com/RayhanHamada/android-cli-gui/releases/download/v#{version}/android-cli-gui-v#{version}-#{arch}.zip"
+ name "Android CLI GUI"
+ desc "Unofficial GUI for the official Android CLI"
+ homepage "https://github.com/RayhanHamada/android-cli-gui"
+
+ depends_on cask: "android-cli"
+ depends_on macos: :sequoia
+
+ app "Android CLI GUI.app"
+
+ uninstall quit: "io.github.rayhanhamada.android-cli-gui"
+
+ zap trash: [
+ "~/Library/Application Support/io.github.rayhanhamada.android-cli-gui",
+ "~/Library/Caches/io.github.rayhanhamada.android-cli-gui",
+ "~/Library/Saved Application State/io.github.rayhanhamada.android-cli-gui.savedState",
+ ]
+
+ caveats "If macOS blocks the first launch, open System Settings > Privacy & Security and choose Open Anyway."
+end
diff --git a/packaging/homebrew/android-cli-gui.rb.tmpl b/packaging/homebrew/android-cli-gui.rb.tmpl
deleted file mode 100644
index 5d69599..0000000
--- a/packaging/homebrew/android-cli-gui.rb.tmpl
+++ /dev/null
@@ -1,24 +0,0 @@
-class AndroidCliGui < Formula
- desc "Unofficial GUI for the official Android CLI"
- homepage "https://github.com/RayhanHamada/android-cli-gui"
- version "__VERSION__"
- depends_on macos: :sequoia
-
- on_macos do
- if Hardware::CPU.arm?
- url "https://github.com/RayhanHamada/android-cli-gui/releases/download/v__VERSION__/android-cli-gui-v__VERSION__-aarch64-apple-darwin.tar.gz"
- sha256 "__SHA256_MACOS_ARM64__"
- else
- url "https://github.com/RayhanHamada/android-cli-gui/releases/download/v__VERSION__/android-cli-gui-v__VERSION__-x86_64-apple-darwin.tar.gz"
- sha256 "__SHA256_MACOS_X86_64__"
- end
- end
-
- def install
- bin.install "android-cli-gui"
- end
-
- test do
- assert_path_exists bin/"android-cli-gui"
- end
-end
diff --git a/packaging/macos/AppIcon.png b/packaging/macos/AppIcon.png
new file mode 100644
index 0000000..3085017
Binary files /dev/null and b/packaging/macos/AppIcon.png differ
diff --git a/packaging/macos/Info.plist b/packaging/macos/Info.plist
new file mode 100644
index 0000000..8b7cc66
--- /dev/null
+++ b/packaging/macos/Info.plist
@@ -0,0 +1,36 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleDisplayName
+ Android CLI GUI
+ CFBundleExecutable
+ android-cli-gui
+ CFBundleIconFile
+ AppIcon
+ CFBundleIdentifier
+ io.github.rayhanhamada.android-cli-gui
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ Android CLI GUI
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ __VERSION__
+ CFBundleVersion
+ __VERSION__
+ LSApplicationCategoryType
+ public.app-category.developer-tools
+ LSMinimumSystemVersion
+ 15.0
+ NSHighResolutionCapable
+
+ NSPrincipalClass
+ NSApplication
+ NSSupportsAutomaticGraphicsSwitching
+
+
+
diff --git a/packaging/macos/make-app.sh b/packaging/macos/make-app.sh
new file mode 100755
index 0000000..c0e6451
--- /dev/null
+++ b/packaging/macos/make-app.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+# Assemble a launchable macOS .app bundle around the release binary.
+#
+# Usage: make-app.sh
+set -euo pipefail
+
+if [[ $# -ne 3 ]]; then
+ echo "usage: $0 " >&2
+ exit 2
+fi
+
+binary=$1
+version=$2
+app=$3
+
+if [[ "$(uname -s)" != "Darwin" ]]; then
+ echo "make-app.sh requires macOS (sips, iconutil, codesign)." >&2
+ exit 1
+fi
+if [[ ! -x "$binary" ]]; then
+ echo "Binary not found or not executable: $binary" >&2
+ exit 1
+fi
+if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ echo "Version must be a semantic version, got: $version" >&2
+ exit 1
+fi
+
+script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+contents="$app/Contents"
+resources="$contents/Resources"
+
+rm -rf "$app"
+mkdir -p "$contents/MacOS" "$resources"
+
+install -m 755 "$binary" "$contents/MacOS/android-cli-gui"
+sed "s/__VERSION__/$version/g" "$script_dir/Info.plist" > "$contents/Info.plist"
+printf 'APPL????' > "$contents/PkgInfo"
+
+iconset="$(mktemp -d)/AppIcon.iconset"
+mkdir -p "$iconset"
+trap 'rm -rf "$(dirname "$iconset")"' EXIT
+for size in 16 32 128 256 512; do
+ sips -z "$size" "$size" "$script_dir/AppIcon.png" \
+ --out "$iconset/icon_${size}x${size}.png" >/dev/null
+ sips -z "$((size * 2))" "$((size * 2))" "$script_dir/AppIcon.png" \
+ --out "$iconset/icon_${size}x${size}@2x.png" >/dev/null
+done
+iconutil -c icns "$iconset" -o "$resources/AppIcon.icns"
+
+plutil -lint "$contents/Info.plist" >/dev/null
+
+# Ad-hoc signing keeps the bundle self-consistent on Apple Silicon. Homebrew
+# downloads do not carry a browser quarantine flag, so no notarization is
+# required for cask installs.
+codesign --force --deep --sign - "$app" >/dev/null
+codesign --verify --deep --strict "$app"
+
+echo "Built $app"
diff --git a/src/android.rs b/src/android.rs
index b95d787..aff62e4 100644
--- a/src/android.rs
+++ b/src/android.rs
@@ -168,15 +168,59 @@ pub fn cli_binary_name() -> &'static str {
}
}
-/// Find the official Android CLI on `PATH`.
+/// Find the official Android CLI on `PATH` or in a standard install location.
+///
+/// macOS apps launched from Finder inherit launchd's minimal `PATH`, not the
+/// login shell's. Homebrew installs the CLI at `/opt/homebrew/bin` (Apple
+/// Silicon) or `/usr/local/bin` (Intel), so check those too.
pub fn find_cli() -> Option {
let name = cli_binary_name();
- let path_var = env::var_os("PATH")?;
- env::split_paths(&path_var)
+ search_paths()
+ .into_iter()
.map(|dir| dir.join(name))
.find(|path| is_executable(path))
}
+fn search_paths() -> Vec {
+ search_paths_from(env::var_os("PATH").as_deref())
+}
+
+fn search_paths_from(path_var: Option<&std::ffi::OsStr>) -> Vec {
+ let mut paths: Vec = path_var
+ .map(env::split_paths)
+ .into_iter()
+ .flatten()
+ .filter(|dir| !dir.as_os_str().is_empty())
+ .collect();
+
+ #[cfg(target_os = "macos")]
+ let extra = ["/opt/homebrew/bin", "/usr/local/bin"];
+ #[cfg(not(target_os = "macos"))]
+ let extra = ["/usr/local/bin"];
+
+ for dir in extra {
+ let dir = PathBuf::from(dir);
+ if !paths.contains(&dir) {
+ paths.push(dir);
+ }
+ }
+
+ if let Some(home) = env::var_os("HOME") {
+ let dir = PathBuf::from(home).join(".local/bin");
+ if !paths.contains(&dir) {
+ paths.push(dir);
+ }
+ }
+
+ paths
+}
+
+/// PATH for child `android` processes. Android tooling invokes helpers such as
+/// `java` and `adb`, so the GUI must hand them the same expanded PATH.
+fn child_path() -> std::ffi::OsString {
+ env::join_paths(search_paths()).unwrap_or_else(|_| env::var_os("PATH").unwrap_or_default())
+}
+
#[cfg(unix)]
fn is_executable(path: &std::path::Path) -> bool {
use std::os::unix::fs::PermissionsExt;
@@ -387,6 +431,7 @@ fn run(
running: &RunningCli,
) -> Result {
let mut command = Command::new(bin);
+ command.env("PATH", child_path());
if let Some(root) = root {
command.arg(format!("--sdk={}", root.display()));
}
@@ -594,6 +639,32 @@ Available packages:
assert!(started.elapsed() < Duration::from_secs(2));
}
+ #[test]
+ fn search_paths_fall_back_to_standard_bin_dirs() {
+ let path_var = env::join_paths([PathBuf::from("/usr/bin"), PathBuf::from("/bin")]).unwrap();
+ let paths = search_paths_from(Some(&path_var));
+
+ assert_eq!(paths[0], PathBuf::from("/usr/bin"));
+ assert!(paths.contains(&PathBuf::from("/usr/local/bin")));
+ #[cfg(target_os = "macos")]
+ assert!(paths.contains(&PathBuf::from("/opt/homebrew/bin")));
+ }
+
+ #[test]
+ fn search_paths_do_not_duplicate_existing_dirs() {
+ let path_var =
+ env::join_paths([PathBuf::from("/usr/local/bin"), PathBuf::from("/usr/bin")]).unwrap();
+ let paths = search_paths_from(Some(&path_var));
+
+ assert_eq!(
+ paths
+ .iter()
+ .filter(|path| *path == &PathBuf::from("/usr/local/bin"))
+ .count(),
+ 1
+ );
+ }
+
#[cfg(unix)]
#[test]
fn only_executable_files_count_as_cli() {
diff --git a/src/app.rs b/src/app.rs
index ef5d22d..eb3ff3b 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -527,26 +527,13 @@ impl App {
.font_weight(FontWeight::SEMIBOLD)
.text_color(cx.theme().danger),
)
- .child(
- Label::new(error)
- .text_size(px(12.))
- .whitespace_normal(),
- )
+ .child(Label::new(error).text_size(px(12.)).whitespace_normal())
.child(
Label::new(
"This app does not bundle the SDK: it reads and modifies the SDK by running \
- the official `android` CLI. Make sure the executable is on the PATH the app \
- inherits.",
- )
- .text_size(px(12.))
- .text_color(muted)
- .whitespace_normal(),
- )
- .child(
- Label::new(
- "On macOS, apps launched from Finder do not read your shell profile, so a CLI \
- added to PATH in .zshrc or .bashrc will not be visible here. Add its directory \
- to the app's environment or launch the app from a terminal.",
+ the official `android` CLI. Install the CLI from \
+ developer.android.com/tools/agents/android-cli, then click Check again. \
+ On macOS the app also checks /opt/homebrew/bin and /usr/local/bin.",
)
.text_size(px(12.))
.text_color(muted)