Skip to content

Add Homebrew tap for installation #303

Description

@mglaman

Currently installation requires manually downloading the phar, marking it executable, and moving it into $PATH:

curl -OL https://github.com/mglaman/drupalorg-cli/releases/latest/download/drupalorg.phar
chmod +x drupalorg.phar
mv drupalorg.phar /usr/local/bin/drupalorg

Homebrew is the standard installation method for CLI tools on macOS. Adding a tap would simplify installation to:

brew install mglaman/drupalorg-cli/drupalorg-cli

Steps

1. Create the tap repository

Create a new public GitHub repo under the mglaman account named homebrew-drupalorg-cli. The homebrew- prefix is required by Homebrew's tap convention.

2. Add the formula

Create Formula/drupalorg-cli.rb in the tap repo:

class DrupalorgCli < Formula
  desc "CLI tool for interacting with Drupal.org"
  homepage "https://github.com/mglaman/drupalorg-cli"
  url "https://github.com/mglaman/drupalorg-cli/releases/download/0.8.0/drupalorg.phar"
  sha256 "REPLACE_WITH_SHA256"
  license "MIT"

  def install
    bin.install "drupalorg.phar" => "drupalorg"
  end

  test do
    system "#{bin}/drupalorg", "--version"
  end
end

Get the SHA256 for the current release:

curl -L https://github.com/mglaman/drupalorg-cli/releases/latest/download/drupalorg.phar | shasum -a 256

3. Automate formula updates on release

Add [mislav/bump-homebrew-formula-action](https://github.com/mislav/bump-homebrew-formula-action) to the main repo so each new release automatically opens a PR against the tap with updated url and sha256 values.

Create .github/workflows/homebrew.yml in mglaman/drupalorg-cli:

name: Update Homebrew formula

on:
  release:
    types: [published]

jobs:
  homebrew:
    runs-on: ubuntu-latest
    steps:
      - uses: mislav/bump-homebrew-formula-action@v3
        with:
          formula-name: drupalorg-cli
          tap-repository: mglaman/homebrew-drupalorg-cli
          download-url: https://github.com/mglaman/drupalorg-cli/releases/download/${{ github.ref_name }}/drupalorg.phar
        env:
          COMMITTER_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}

HOMEBREW_TAP_TOKEN is a fine-grained personal access token with write access to mglaman/homebrew-drupalorg-cli.

Installation (once live)

# With explicit tap
brew tap mglaman/drupalorg-cli
brew install drupalorg-cli

# Or in one line
brew install mglaman/drupalorg-cli/drupalorg-cli

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions