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 metal-cli #1

Merged
merged 2 commits into from
Jan 14, 2022
Merged

Add metal-cli #1

merged 2 commits into from
Jan 14, 2022

Conversation

displague
Copy link
Member

@displague displague marked this pull request as draft December 3, 2021 20:22
@displague
Copy link
Member Author

This draft represents my first guess at what this configuration will look like. I haven't found supported examples to demonstrate how a single binary should be fetched and then renamed at install. Examples that I have found expect a tar ball.

@displague
Copy link
Member Author

It seems that a tar ball may be needed.

Alternatively, we could take the build approach. I do not know if goreleaser handled updates to this package format (build vs binary):

diff --git a/Formula/metal-cli.rb b/Formula/metal-cli.rb
index c403353..f792068 100644
--- a/Formula/metal-cli.rb
+++ b/Formula/metal-cli.rb
@@ -2,43 +2,21 @@
 # frozen_string_literal: true
 
 # This file was generated by GoReleaser. DO NOT EDIT.
-class MetalCLI < Formula
+class MetalCli < Formula
   desc "Equinix Metal CLI"
   homepage "https://githubcom/equinix/metal-cli"
   version "0.6.0"
   license "MIT"
+  url "https://api.github.com/repos/equinix/metal-cli/tarball/v0.6.0"
 
-  on_macos do
-    if Hardware::CPU.intel?
-      url "https://github.com/equinix/metal-cli/releases/download/v0.6.0/metal-darwin-amd64"
-      sha256 "ebcb8bd18e83bd39a6a6cf711802654b349f83c7f75de27e1113b704d9682315"
-      def install
-        bin.install "metal-darwin-amd64" => "metal"
-      end
-    end
-  end
+  depends_on "go" => :build
 
-  on_linux do
-    if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
-      url "https://github.com/equinix/metal-cli/releases/download/v0.6.0/metal-linux-armv6"
-      sha256 "67f8aff5a2fdc156a192125f0b2d9cd73208da5a764b71b247f41c996d13e8b2"
-      def install
-        bin.install "metal-linux-armv6" => "metal"
-      end
-    end
-    if Hardware::CPU.intel?
-      url "https://github.com/equinix/metal-cli/releases/download/v0.6.0/metal-linux-amd64"
-      sha256 "50f575b8e5355cd603df3bcae4ceac30fe4fdec63da61d2fb06f02163fb267d2"
-      def install
-        bin.install "metal-linux-amd64" => "metal"
-      end
-    end
-    if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
-      url "https://github.com/equinix/metal-cli/releases/download/v0.6.0/metal-linux-arm64"
-      sha256 "36797022316a2fc62db884170d2946eef9022848aa5540419b08d8d0d25e1569"
-      def install
-        bin.install "metal-linux-arm64" => "metal"
-      end
+  def install
+    ENV["GOPATH"] = HOMEBREW_CACHE/"go_cache"
+    (buildpath/"src/github.com/equinix/metal-cli").install buildpath.children
+
+    cd "src/github.com/equinix/metal-cli" do
+      system "go", "build", "-o", bin/"metal", "cmd/metal/main.go"
     end
   end
 

Signed-off-by: Marques Johansson <mjohansson@equinix.com>
@displague displague marked this pull request as ready for review January 14, 2022 18:30
@displague displague merged commit 950b7d0 into main Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Install via brew?
1 participant