Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📎 Create Homebrew formula #209

Closed
3 of 4 tasks
nhedger opened this issue Sep 9, 2023 · 11 comments
Closed
3 of 4 tasks

📎 Create Homebrew formula #209

nhedger opened this issue Sep 9, 2023 · 11 comments
Assignees
Labels
A-Tooling Area: internal tools

Comments

@nhedger
Copy link
Member

nhedger commented Sep 9, 2023

Description

This task tracks the publication of Biome to Homebrew.

  • Create Homebrew formula
  • Submit to homebrew/core
  • Update docs
  • Update workflow to release a new version automatically

Discussed in #197

@nhedger
Copy link
Member Author

nhedger commented Sep 9, 2023

Please assign me to the issue.

@ematipico ematipico added the A-Tooling Area: internal tools label Sep 9, 2023
@nhedger
Copy link
Member Author

nhedger commented Sep 9, 2023

I've got a working formula, but we should wait for the next release of the CLI (which renames rome_cli to biome_cli) before submitting it, otherwise, we'll have to update the formula with the new biome_cli name afterwards.

class Biome < Formula
  desc "Toolchain of the web"
  homepage "https://biomejs.dev/"
  url "https://github.com/biomejs/biome.git",
      tag:      "cli/v1.1.2",
      revision: "cde65810dc5a5fa0be30da9ddfe27d2769e71731"
  license "MIT"

  depends_on "rust" => :build

  def install
    cd "crates/rome_cli" do
      system "cargo", "install", "--bin", "biome", *std_cargo_args
    end
  end

  test do
    unformatted = "const x = 1"

    # Write the unformatted code to a file
    (testpath/"test.js").write(unformatted)

    # Run the formatter
    system "#{bin}/biome", "format", "--semicolons=always", "--write", (testpath/"test.js")

    # Read the formatted file
    formatted = (testpath/"test.js").read

    expected = "const x = 1;"

    # Assert that the expected and formatted match
    assert_match expected, formatted
  end
end

Todo

Once a new release is made for the CLI:

  • Rename the tag
  • Update the revision
  • Rename rome_cli to biome_cli

@ematipico
Copy link
Member

How will the publishing process work with homebrew?

At the moment we compile for production using GitHub actions, and they contain environment variables required during the release (version, release flags, etc.)

@nhedger
Copy link
Member Author

nhedger commented Sep 9, 2023

This can either be done manually after each release by running the following command:

brew bump-formula-pr \
  --strict biome \
  --tag="cli/vX.Y.Z" \
  --revision="<commit sha>"

Or can be automated using the following GitHub Action, which wraps the previous script.

https://github.com/marketplace/actions/homebrew-bump-formula


Homebrew will create pre-compiled versions of the formula to distribute.

If there are specific flags that should be passed to the compilation step, we should add them to the formula.

To be clear, we would not directly share compiled binaries.

@nhedger
Copy link
Member Author

nhedger commented Sep 10, 2023

We might be able to add a livecheck block to the formula so that Homebrew's bot automatically maintains this for us. I'll explore this solution and report my findings here.

@nhedger
Copy link
Member Author

nhedger commented Sep 10, 2023

The following livecheck block will detect new versions of the CLI.

  • Ensures that only releases of the CLI are detected
  • Excludes pre-releases and drafts
  livecheck do
    url :stable
    regex(/^cli\/v(\d+(?:\.\d+)+)$/i)
    strategy :github_releases do |json, regex|
      json.map do |release|
        next if release["draft"] || release["prerelease"]

        match = release["tag_name"]&.match(regex)
        next if match.blank?
        
        match[1]
      end
    end
  end

@nhedger
Copy link
Member Author

nhedger commented Sep 15, 2023

v1.2.0 of the CLI has been released, so I'll proceed with this.

@nhedger
Copy link
Member Author

nhedger commented Sep 17, 2023

Biome CLI v1.2.2 is now available on Homebrew.

https://formulae.brew.sh/formula/biome

I'll keep this issue open for now because we still need to integrate the formula version bumping strategy in the release workflow.

For reference, here's the formula PR: Homebrew/homebrew-core#143196

@ematipico
Copy link
Member

Can we close this @nhedger ? What's missing?

@nhedger
Copy link
Member Author

nhedger commented Oct 2, 2023

I still have to update the workflow to automatically bump the version on homebrew's side when we release a new version.

@nhedger
Copy link
Member Author

nhedger commented Oct 20, 2023

Closing in favor of #568

@nhedger nhedger closed this as completed Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Tooling Area: internal tools
Projects
None yet
Development

No branches or pull requests

2 participants