Skip to content

Add Homebrew Support and Cross-Compilation Pipeline#17

Merged
topheman merged 7 commits intomasterfrom
feat/add-homebrew-and-cross-compile
Sep 3, 2025
Merged

Add Homebrew Support and Cross-Compilation Pipeline#17
topheman merged 7 commits intomasterfrom
feat/add-homebrew-and-cross-compile

Conversation

@topheman
Copy link
Copy Markdown
Owner

@topheman topheman commented Sep 3, 2025

This PR adds comprehensive cross-compilation support and Homebrew distribution capabilities to the pluginlab crate.

🚀 Main Features

1. Generate Completions Command

  • Added generate-completions subcommand to pluginlab CLI
  • Supports bash, fish, and zsh shell completions
  • Uses clap_complete crate for generation
  • Completions are bundled with cross-compiled binaries for Homebrew distribution
  • Inspiration: This feature is inspired by a similar implementation in my previous project snake-pipe-rust, where shell completions are automatically installed with Homebrew and can be generated manually for other installation methods

2. Cross-Compilation Pipeline

  • New workflow: .github/workflows/cross-compile.yml
  • Uses houseabsolute/actions-rust-cross@v1 for efficient cross-compilation
  • Targets supported:
    • x86_64-unknown-linux-gnu (Linux Intel)
    • aarch64-unknown-linux-gnu (Linux ARM)
    • x86_64-apple-darwin (macOS Intel)
    • aarch64-apple-darwin (macOS ARM)
  • Features:
    • Binaries are stripped for smaller size
    • Generated completions are bundled with each binary
    • Archives are created as .tar.gz files
    • Caching for faster builds

3. Release Management

  • Enhanced release workflow: Updated .github/workflows/rust-host.yml
  • Uses topheman/create-release-if-not-exist@v1 to allow multiple jobs to upload to the same release
  • Both WASM files and cross-compiled binaries (generated in different jobs) are uploaded to releases
  • Release artifacts include:
    • WASM plugin files (existing)
    • Cross-compiled binaries with completions (new)

4. Homebrew Integration

  • New workflow: .github/workflows/update-homebrew-tap.yml
  • Automatically updates Homebrew formula when releases are published
  • Uses topheman/update-homebrew-tap@v2
  • Updates formula in topheman/homebrew-tap repository
  • Supports multiple target architectures for universal compatibility

📦 Installation Options

Users can now install pluginlab via:

# From source (existing)
cargo install pluginlab

# Via Homebrew (new)
brew install topheman/tap/pluginlab

🔧 Technical Changes

CLI Enhancements

  • Added clap_complete dependency for shell completion generation
  • Restructured CLI to support subcommands
  • --repl-logic is now optional (only required for REPL mode)
  • New generate-completions subcommand with shell selection

Workflow Improvements

  • Cross-compilation runs on multiple platforms (Ubuntu, macOS, ARM runners)
  • Efficient caching strategy for compiled artifacts
  • Parallel upload of artifacts to releases
  • Automatic Homebrew formula updates on release

🎯 Benefits

  1. Better Developer Experience: Shell completions for all supported shells
  2. Wider Distribution: Homebrew makes installation easier for macOS users
  3. Cross-Platform Support: Native binaries for all major platforms
  4. Automated Releases: Streamlined release process with automatic Homebrew updates
  5. Performance: Stripped binaries and efficient caching reduce build times

🔗 Custom GitHub Actions Used

This implementation leverages the following custom GitHub actions I've created:

I also used topheman/update-homebrew-tap-playground as a playground to test those in isolation.


This PR significantly improves the distribution and usability of pluginlab by providing native binaries for main platforms and seamless Homebrew integration, while maintaining the existing functionality and adding shell completions for better developer experience.

…ew-tap

Relies on:

- https://github.com/topheman/create-release-if-not-exist : github
  action that creates a release if not exist - allows to upload
artefacts to a same release from multiple parallel workflows
- https://github.com/topheman/update-homebrew-tap : github action that
  updates a homebrew tap repo based on the user's template

The homebrew taps are published by the github actions above to https://github.com/topheman/homebrew-tap

Now you can install the crate without needing to compile it from source
with `cargo install`. Use:

`brew install topheman/tap/pluginlab`

Prebuilt binaries (built at the cross-compile step) for linux/macOS
x86_64/macOS arm will be chosen.
@topheman topheman self-assigned this Sep 3, 2025
@topheman topheman merged commit 91d6326 into master Sep 3, 2025
12 checks passed
@topheman topheman deleted the feat/add-homebrew-and-cross-compile branch September 3, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant