dream11 / homebrew-tools

Homebrew tap formula(s) for Dream11 internal tools.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

homebrew-tools 🍺

Homebrew tap formula(s) for Dream11 tools.

Tap

brew tap dream11/tools

Install

brew install dream11/tools/<formula name>

Can run directly without running brew tap.

Example

brew install dream11/tools/odin

Development

Repository structure

+-- homebrew-tools
    +-- formula
        +-- tool.rb
        +-- lib
            +-- function.rb

formula

Contains all installation formula(s).

formula/lib

Contains all library functions required by the formula(s).

Writing a formula

Importing libraries

Importing library from formula/lib/library.rb

require_relative "lib/library"

Initiating a formula class

class Odin < Formula
  desc "Formula description"
  homepage "https://github.com/dream11/tool-name"
  version "1.0.0"

  # add installation steps here

end

Example: Formula for installing a binary

Pre-requisites

For a repository github.com/dream11/tool -

  1. Create a tag 1.0.0.
  2. Create a release, from above tag.
  3. Attach the compiled binary tool, compressed within tool_os_arch.tar.gz.

Formula

Create a formula, homebrew-tools/formula/tool.rb,

If repository is public,

# typed: false

class Tool < Formula
  desc "Tool description"
  homepage "https://github.com/dream11/tool"
  version "1.0.0"

  # For MacOs Intel based systems
  if OS.mac? && Hardware::CPU.intel?
    url "https://github.com/dream11/tool/releases/download/1.0.0/tool_darwin_amd64.tar.gz"
    sha256 "<sha256 of tool_darwin_amd64.tar.gz>"
  end

  # For MacOs M1 based systems
  if OS.mac? && Hardware::CPU.arm?
    url "https://github.com/dream11/tool/releases/download/1.0.0/tool_darwin_arm64.tar.gz"
    sha256 "<sha256 of tool_darwin_arm64.tar.gz>"
  end

  conflicts_with "tool"

  def install
    bin.install "tool"
  end

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

end

Install by running,

brew install dream11/tools/<tool>

If repository is private,

# typed: false
require_relative "lib/github"

class Tool < Formula
  desc "Tool description"
  homepage "https://github.com/dream11/tool"
  version "1.0.0"

  # For MacOs Intel based systems
  if OS.mac? && Hardware::CPU.intel?
    url "https://github.com/dream11/tool/releases/download/1.0.0/tool_darwin_amd64.tar.gz", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
    sha256 "<sha256 of tool_darwin_amd64.tar.gz>"
  end

  # For MacOs M1 based systems
  if OS.mac? && Hardware::CPU.arm?
    url "https://github.com/dream11/tool/releases/download/1.0.0/tool_darwin_arm64.tar.gz", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
    sha256 "<sha256 of tool_darwin_arm64.tar.gz>"
  end

  conflicts_with "tool"

  def install
    bin.install "tool"
  end

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

end

Install by running,

# A github personal access token will be required to access the private repository
export HOMEBREW_GITHUB_API_TOKEN=<Github API token>

brew install dream11/tools/<tool>

Formula Version

To enable brew install tool@version. Write the formula as stated here, just change the class name according to the convention and place it in the file named as homebrew-tools/formula/tool@<version>.rb.

Example - odin.rb v/s odin@1.0.0-alpha.rb

Class naming convention

  1. For tool, class name becomes Tool

  2. For tool@version, class name becomes ToolAt<Version> a. version 1.0.0 gives - ToolAt100 b. version 1.0.0-beta gives - ToolAt100Beta

Installation

export HOMEBREW_GITHUB_API_TOKEN=<your github access token>
brew tap dream11/tools
brew install dream11/tools/tool

About

Homebrew tap formula(s) for Dream11 internal tools.


Languages

Language:Ruby 100.0%