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

add brew tap for porter #3045

Closed
Tracked by #3113
kurktchiev opened this issue Mar 28, 2024 · 18 comments
Closed
Tracked by #3113

add brew tap for porter #3045

kurktchiev opened this issue Mar 28, 2024 · 18 comments
Assignees
Labels
good first issue Good for new contributors help wanted Good for someone who has contributed before suggestion Idea for maintainers to consider. Do not take this issue until triaged.

Comments

@kurktchiev
Copy link

Is your feature request related to a problem? Please describe.
Currently, the install process for Mac/others is through shell script. It would be beneficial to have brew install tap be created for simpler binary management on mac. Similar tools exist for most other platforms as well.

Describe the solution you'd like
A clear and concise description of what you want to happen. Provides information on how to do a cask or formula. However, I believe there is some go tooling that can auto-generate this for a project (still searching for the appropriate doc)

Additional context
The current install script method is error-prone and reliant on multiple updates within the infrastructure; this would simplify it.

@kurktchiev kurktchiev added the suggestion Idea for maintainers to consider. Do not take this issue until triaged. label Mar 28, 2024
@schristoff schristoff added help wanted Good for someone who has contributed before good first issue Good for new contributors labels Mar 28, 2024
@schristoff schristoff moved this to Todo in v1.1.0 (June 2024) Apr 4, 2024
@dgannon991
Copy link
Member

I started taking a look into this, but we first need to fix the building from the .tar.gz file (#3064) as the formula I'm attempting to create fails at this stage.

@neeginotra
Copy link

I started looking at this issue as per the last standup.

@dgannon991
Copy link
Member

Hi @neeginotra,

I made a quick start on this, but got quite quickly blocked by the inability to build the project from source.

If it's of any use to you, here was my formula. I never got as far as verifying if the format was right for the test section, as the install fell over.

# Documentation: https://docs.brew.sh/Formula-Cookbook
#                https://rubydoc.brew.sh/Formula
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
class Porter < Formula
  desc "Porter enables you to package your application artifact, client tools, configuration and deployment logic together as an installer that you can distribute, and install with a single command."
  homepage "https://porter.sh"
  url "https://github.com/getporter/porter/archive/refs/tags/v1.0.17.tar.gz"
  sha256 "5262251aba930331b0e3b83cb971f6d138611b37b81af621606b6578739b5e9a"
  license "Apache-2.0"

  depends_on "go" => :build

  def install
    system "go", "run", "mage.go", "Build"
  end

  test do
    assert_match "1.0.17", shell_output("#{bin}/porter version")
  end
end

D

@neeginotra
Copy link

hello @dgannon991
Thanks for sharing. I will run build again to confirm.

@devc007
Copy link

devc007 commented Apr 18, 2024

Hey @neeginotra
Are you still working on this issues, let me know if you are working on this or not. I have read some of the documentation related this and want to try.

@SpiffyEight77
Copy link
Contributor

SpiffyEight77 commented May 11, 2024

@schristoff

Sorry to bother you at this moment. 🙇🏻‍♂️
It appears that this issue has been unresolved for a while and no one has taken action on it, so I decided to give it a try.

First of all, thank you for providing the basic formula script by @dgannon991. This script has been very helpful to me.
However, due to the latest release v1.0.17 of Porter and its magefiles version 0.6.3, it will cause another issue #3064. I am aware that this issue has been fixed in subsequent versions.

To verify the formula construction, I fork this repository and updated the magefiles dependency to version 0.6.5. I executed the following command on my local machine and it worked, but there is still a minor issue when running the version command.

HOMEBREW_NO_INSTALL_FROM_API=1 brew install --verbose --build-from-source porter.rb

class Porter < Formula
  desc "Porter enables you to package your application artifact, client tools, configuration and deployment logic together as an installer that you can distribute, and install with a single command."
  homepage "https://porter.sh/"
  url "https://github.com/SpiffyEight77/porter/archive/refs/tags/v1.0.17.1.tar.gz"
  sha256 "2139036410612d28a455575066101aa9fcc0e231048d5b7b5c295ba207efd0ff"
  license "Apache-2.0"
  head "https://github.com/getporter/porter.git", branch: "main"

  depends_on "go" => :build

  def install
    system "go", "run", "mage.go", "-v", "Build"

    bin.install "bin/porter"

    generate_completions_from_executable(bin/"porter", "completion")
  end

  test do
    assert_predicate bin/"porter", :exist?, "porter binary doesn't exist"

    assert_match "porter v1.0.17.1 (4157be0)", shell_output("#{bin}/porter version")
  end
end

porter version
porter v0.0.0 (0000000)

If I build from the specified commit as shown below, everything will work well.

HOMEBREW_NO_INSTALL_FROM_API=1 brew install --verbose --build-from-source porter.rb

class Porter < Formula
  desc "Porter enables you to package your application artifact, client tools, configuration and deployment logic together as an installer that you can distribute, and install with a single command."
  homepage "https://porter.sh"
  url "https://github.com/getporter/porter.git",
    tag:      "v1.0.17",
    revision: "605e399737c5c89f0ce692c6aa3d9e6211250c95"
  license "Apache-2.0"
  head "https://github.com/getporter/porter.git", branch: "main"

  depends_on "go" => :build

  def install
    system "go", "run", "mage.go", "-v", "Build"

    bin.install "bin/porter"

    generate_completions_from_executable(bin/"porter", "completion")
  end

  test do
    assert_predicate bin/"porter", :exist?, "porter binary doesn't exist"

    assert_match "porter v1.0.17 (605e3997)", shell_output("#{bin}/porter version")
  end
end

porter version
porter v1.0.17 (605e3997)

We need to submit the script mentioned above which build from the source code without git, following the rule of homebrew contribution.

Here is the draft PR #171414 for this formula issue.

I plan to fix the version command issue caused by magefiles, and then wait for the new version of porter to be released, where the magefiles version is the latest. Finally, I will update the URL in the script to the official repository and submit the formula to homebrew-core.

I'm highly interested in this matter and actively working on it. Could you @schristoff kindly assign it to me? 🙇🏻‍♂️

@schristoff
Copy link
Member

@SpiffyEight77 Not a bother at all. I look forward to your PR. Thank you so much :)

@SpiffyEight77
Copy link
Contributor

@schristoff

Sorry to bother you.

This task is nearly complete.

Should I wait for the v1.1.0 release before resubmitting the formula?

Additionally, I'd like to create a new issue to track the problem of writing environment variables into GHA for the Trivy CI. I hope to make it more flexible and remove the hardcoding that skips writing during building formula.

By the way, I've opened a new issue to discuss various installation methods for Porter across different Linux distributions. I'd like to hear your thoughts on this. 🙇🏻‍♂️

@schristoff
Copy link
Member

Hey @SpiffyEight77 - I think it would be great for Porter to be in multiple package managers, but only if we have an automated way to keep releases up to date with all of them!
I think it is okay to use the current release and push that to the tap, that way we can make sure it works, and then v1.1.0 will automagically be pushed out to Homebrew :)

@SpiffyEight77
Copy link
Contributor

@schristoff
Thanks for your reply.

I think it would be great for Porter to be in multiple package managers, but only if we have an automated way to keep releases up to date with all of them!

I'll try to figure out how to implement this in my free time.

I think it is okay to use the current release and push that to the tap, that way we can make sure it works, and then v1.1.0 will automagically be pushed out to Homebrew :)

To make sure it works, I suggest to release the latest version v0.6.7 of the magefiles, which includes updates for building homebrew formulas. Following that, we can re-release v1.0.17 of the porter with the updated v0.6.7 magefiles.

Looking forward to your reply. 🙇🏻‍♂️

@schristoff
Copy link
Member

Hey @SpiffyEight77 - I just cut v1.1.0-rc - expect binaries to be on GH in about an 1hr~
Let me know what else we can do to get Porter a homebrew tap :)

@SpiffyEight77
Copy link
Contributor

@schristoff
Thank you so much for releasing v1.1.0-rc.

Unfortunately, homebrew/core is not accept to ship any rc release, so that I'll submit a new PR for v1.1.0-rc to getporter/homebrew later tonight.

Once version 1.1.0 is released, I will process the existing PR in Homebrew-core. 🙇🏻‍♂️

@schristoff
Copy link
Member

🤦‍♀️🤦‍♀️🤦‍♀️🤦‍♀️ I did not know that

@SpiffyEight77
Copy link
Contributor

@schristoff
It's acceptable to keep both the tap and core available simultaneously, offering users two methods for installing Porter using brew.

getporter/homebrew offers a pre-release version of Porter for installation.

@SpiffyEight77
Copy link
Contributor

@schristoff
Sorry to bother you at this moment.

I forked the repository and attempted to install Porter using the Homebrew tap command, but the installation failed because https://cdn.porter.sh/mixins/atom.xml has not been updated yet.

❯ brew install SpiffyEight77/homebrew/porter
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Auto-updated Homebrew!
Updated 1 tap (spiffyeight77/homebrew).
No changes to formulae or casks.

==> Fetching spiffyeight77/homebrew/porter
==> Cloning https://github.com/getporter/porter.git
Updating /Users/wayne/Library/Caches/Homebrew/porter--git
From https://github.com/getporter/porter
 * [new tag]           v1.1.0-rc  -> v1.1.0-rc
==> Checking out tag v1.1.0-rc
Previous HEAD position was 5621f32b release: porter v1.0.17
HEAD is now at eeeaa29f Merge pull request #3135 from kichristensen/runSigningIntegrationTest
HEAD is now at eeeaa29f Merge pull request #3135 from kichristensen/runSigningIntegrationTest
==> Installing porter from spiffyeight77/homebrew
==> mage -v BuildPorter
==> /opt/homebrew/Cellar/porter/1.1.0-rc/bin/porter mixin install exec --version v1.1.0-rc
Last 15 lines from /Users/wayne/Library/Logs/Homebrew/porter/02.porter:
2024-06-04 14:05:19 +0000

/opt/homebrew/Cellar/porter/1.1.0-rc/bin/porter
mixin
install
exec
--version
v1.1.0-rc

the feed at https://cdn.porter.sh/mixins/atom.xml does not contain an entry for exec @ v1.1.0-rc
the feed at https://cdn.porter.sh/mixins/atom.xml does not contain an entry for exec @ v1.1.0-rc

If reporting this issue please do so to (not Homebrew/brew or Homebrew/homebrew-core):
  spiffyeight77/homebrew

Warning: Unable to query GitHub for recent issues on the tap
Validation Failed: [{"message"=>"The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.", "resource"=>"Search", "field"=>"q", "code"=>"invalid"}]

@SpiffyEight77
Copy link
Contributor

SpiffyEight77 commented Jun 8, 2024

Hey @schristoff, sorry to bother you.

The easiest way to pass the CI of homebrew-core when building porter is to use the go build command directly instead of mage build.

The constraints on the mage build are too many, causing me to be stuck in a dead end and I'm so sorry that wasting your time to release the v1.1.0-rc for this issue.🙇🏻‍♂️

I will submit the PR to revert the change I have made to the magefiles.

Please review the PR for Homebrew-core at your convenience.

If there is no problem for the PR, I will re-request review again.🙇🏻‍♂️

@kichristensen kichristensen moved this from Todo to In Progress in v1.1.0 (June 2024) Jun 9, 2024
@SpiffyEight77
Copy link
Contributor

Hey @schristoff @kichristensen, sorry to disturb you right now. Porter has been added to homebrew-core. We can now use the command brew install porter to install porter on macOS. However, there's an issue with the installation process: the porter installation script automatically installs the exec mixin as well, which violates homebrew-core guidelines. Therefore, using brew will only install porter itself.


==> Downloading https://ghcr.io/v2/homebrew/core/porter/manifests/1.1.0
######################################################################################################################################################################################################################## 100.0%
==> Fetching porter
==> Downloading https://ghcr.io/v2/homebrew/core/porter/blobs/sha256:5132b84b398bfa7cc1fcc82143d0dca926be611cd13180c33cd3708e7c73e5df
######################################################################################################################################################################################################################## 100.0%
==> Pouring porter--1.1.0.arm64_sonoma.bottle.tar.gz
==> Caveats
zsh completions have been installed to:
  /opt/homebrew/share/zsh/site-functions
==> Summary
🍺  /opt/homebrew/Cellar/porter/1.1.0: 9 files, 55.7MB
==> Running `brew cleanup porter`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

~ took 6s
❯ porter version
porter 1.1.0 (Homebrew)

@kichristensen
Copy link
Contributor

@SpiffyEight77 Thanks for getting this through and added to homebrew. We will formulate a plan for handling mixins better in the future, to avoid the challenge with the exec mixin

@github-project-automation github-project-automation bot moved this from In Progress to Done in v1.1.0 (June 2024) Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for new contributors help wanted Good for someone who has contributed before suggestion Idea for maintainers to consider. Do not take this issue until triaged.
Projects
Status: Done
Development

No branches or pull requests

7 participants