seqeralabs / wave-cli

Command line tool for Wave containers provisioning service
https://seqera.io/wave
Apache License 2.0
13 stars 3 forks source link

Add CI action to publish wave-cli to homebrew #37

Closed munishchouhan closed 11 months ago

munishchouhan commented 1 year ago

This PR will add the following:

  1. Homebrew formula for AMD and ARM MAC distributions
  2. Change mac binaries to zip
  3. Change Github_Token to JRELEASER_GITHUB_TOKEN
  4. Add packagers section in Jreleaser to publish brew formula to homebrew-tap repo
pditommaso commented 1 year ago

@marcodelapierre can you please test this?

marcodelapierre commented 1 year ago

The added formula file seems reasonable.

However, as far as I understand (I am new to JReleaser), we also need a jreleaser.yml in the root dir, with a packages: brew: section, as per the YAML example in https://jreleaser.org/guide/latest/reference/packagers/homebrew.html .

In fact, I also see that tower-cli has such a file: https://github.com/seqeralabs/tower-cli/blob/master/jreleaser.yml

Munish can you investigate this aspect?

After this addition, I imagine that testing the github workflow on a test repo (personal fork?) should result in the Brew artifact being created.

marcodelapierre commented 1 year ago

Also, note this note in the jreleaser page for homebrew:

JReleaser does not generate a valid homebrew-core formula. The generated formulas are meant to be published as [homebrew taps](https://docs.brew.sh/Taps.html), and in their current form will not be accepted in any of the official homebrew repositories.

This seems to imply some additional steps.

Look at the this brew help output:

$ brew help tap
Usage: brew tap [options] [user/repo] [URL]

Tap a formula repository. If no arguments are provided, list all installed taps.

With URL unspecified, tap a formula repository from GitHub using HTTPS. Since
so many taps are hosted on GitHub, this command is a shortcut for brew tap
user/repo https://github.com/user/homebrew-repo.

I think we should be setting up a seqeralabs/homebrew-SOMETHING to host our brew formulas.

Then users will be able to do:

# only once
brew tap seqera/SOMETHING

# and then any time needed
brew install wave
brew install tower-agent
brew install tower-cli
......

@pditommaso if this makes sense, then @munishchouhan you could take care of this after the YAML step above is done.

Thoughts?

pditommaso commented 1 year ago

@pditommaso if this makes sense, then @munishchouhan you could take care of this after the YAML step above is done.

Yes please! what other projects do usually use for the SOMETHING part?

marcodelapierre commented 1 year ago

I think I just love Hashicorp's take, they use tap, as in: seqeralabs/tap

Then:

brew tap seqeralabs/tap
brew install wave-cli
brew install tower-cli
..

# or, equivalently I think, without the initial tap
brew install seqeralabs/tap/wave-cli
brew install seqeralabs/tap/tower-cli
..

https://www.hashicorp.com/blog/announcing-hashicorp-homebrew-tap

It makes sense for us, as we may have a limited number of formulas to provide (currently no more than 5 : wave-cli, tower-cli, tower-agent, seqera-kit?), so I don't see scope for having multiple named SOMETHING.

Ubuntu uses ubuntu/microk8s, but I cannot see a parallel for us (https://github.com/ubuntu/homebrew-microk8s)

So I suggest creating the new repo github.com/seqeralabs/homebrew-tap .

marcodelapierre commented 1 year ago

@ewels pointed out that having to resort the custom tap can be annoying to users.

This is currently a requirement due to JReleaser restriction.

So:

marcodelapierre commented 1 year ago

For reference: JReleaser page on Homebrew: https://jreleaser.org/guide/latest/reference/packagers/homebrew.html

pditommaso commented 1 year ago

I think the custom tap is fine. I've seen many times. The tap naming is ok!

ewels commented 1 year ago

Phil, how bad of a constraint is this? Should we look into opening an issue with JReleaser to improve on this?

Not bad - as discussed in the meeting, main downside is that it requires people to read the Seqera docs and copy + paste commands rather than just searching Homebrew or doing brew search wave (ie. better discoverability in core formula).

Phil: is it possible to have homebrew core formula collection to accept syncing of our custom tap??

We looked into this a bit during the meeting and it's not just pushing to the core collection that's an issue, it's that JReleaser creates manifests that are not valid for the core collection. Sounds like there might be quite a bit of work involved (?) so probably not worth it.

marcodelapierre commented 1 year ago

@munishchouhan when you are back, I think we are ready to go ahead and work on the updated jreleaser.yml, see comment further up : https://github.com/seqeralabs/wave-cli/pull/37#issuecomment-1820202263

munishchouhan commented 12 months ago

new repo has been created for home brew tap https://github.com/seqeralabs/homebrew-tap

marcodelapierre commented 12 months ago

Thanks for the progress Munish!
Are there any more required steps to enable us testing the functionality?

E.g. we could have a condition on the brew formula workflow, that checks for a string in the commit name, such as [test brew]

aalmiray commented 12 months ago

FWIW core formulae are supposed to be built from source. At the moment JReleaser builds formulae from binaries, which is why taps are preferred.

Discoverability is hindered a bit when using taps as one must perform one extra step (linking the tap) before installing the target formula. However, it's a known practice up to a certain point.

munishchouhan commented 12 months ago

@aalmiray, thanks for the input, we have created the formula to directly use binaries and for the JReleaser part, is there a way to test the publishing part locally or in a fork?

aalmiray commented 12 months ago

Yes, you can invoke either the prepare or package commands in JReleaser. This will generate the formula inside the out/jreleaser/ directory, which you may install from source using brew. Be advised that you may need to update the url: to point to a local path in your filesystem as the formula will expect the published url to be available by default.

munishchouhan commented 11 months ago

I am testing here https://github.com/munishchouhan/wave-cli/actions/runs/

marcodelapierre commented 11 months ago

how is the testing going?

munishchouhan commented 11 months ago

Currently, I am getting this warning, so I will create a zip distribution for homebrew [WARN] distribution.wave-cli.brew was disabled because there are no matching artifacts [.zip]

aalmiray commented 11 months ago

Be advised on the different types of distributions supported by JReleaser. Given your current setup you need either of these 2

https://jreleaser.org/guide/latest/concepts/distributions/binary.html

https://jreleaser.org/guide/latest/concepts/distributions/flat-binary.html

munishchouhan commented 11 months ago

@marcodelapierre @pditommaso I got this working now you can check https://github.com/munishchouhan/wave-cli/actions/runs/7102346973 https://github.com/munishchouhan/homebrew-tap

munishchouhan commented 11 months ago

But still need to figure out the platform part because we have to publish it for AMR and x86

munishchouhan commented 11 months ago

A new GitHub token is required, which have access to write on https://github.com/seqeralabs/homebrew-tap

@jordigg, can you please generate a Github token with the necessary permissions and put it in the environment of this repository?

marcodelapierre commented 11 months ago

A new GitHub token is required, which have access to write on https://github.com/seqeralabs/homebrew-tap

@jordigg, can you please generate a Github token with the necessary permissions and put it in the environment of this repository?

@munishchouhan isn't this something we can do ourselves?

If not, and if Jordi has not actioned this yet, I suggest you raise an internal help-it request to bring it to his attention.

jordigg commented 11 months ago

@marcodelapierre @munishchouhan I reached out via Slack to Munish about this.

As far as I know, there are two types of credentials you can use. Organization credentials or a "service account", and I'm not sure which one you need.

For other CI work, the engineering team uses the seqera-sa-eng account which is stored in 1Password under the Engineering Vault. You can login and set up anything you need in there. I'm trying not to be a blocker, so I prefer for people to self-serve and if something depends on me we change it. I have added the seqera-sa-eng to a ci-automation group and gave it write permissions to this repo. I don't think the Repo has any admin, not sure which team should have this.

Let me know if you need me to do anything.

munishchouhan commented 11 months ago

@jordigg please give this user seqera-sa-eng write permission on homebrew-repo also

jordigg commented 11 months ago

@munishchouhan done. I have added [ci-automation](https://github.com/orgs/seqeralabs/teams/ci-automation) to the repo.

munishchouhan commented 11 months ago

@pditommaso @marcodelapierre @jordeu This PR is ready for review you can test this by following the instructions mentioned in the below repository https://github.com/munishchouhan/homebrew-tap

marcodelapierre commented 11 months ago

Finally, I propose to expand the readme in the Tap repository: https://github.com/seqeralabs/homebrew-tap/pull/1

marcodelapierre commented 11 months ago

Thanks Munish!

munishchouhan commented 11 months ago

@pditommaso Please review this PR

marcodelapierre commented 11 months ago

@pditommaso Homebrew support for Wave CLI merged