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

Use new formula with dynamic versioning #18

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 0 additions & 72 deletions ConfigProvider/config_provider.rb

This file was deleted.

94 changes: 44 additions & 50 deletions Formula/smithy-cli.rb
Original file line number Diff line number Diff line change
@@ -1,58 +1,52 @@
# -*- coding: utf-8 -*-
require_relative '../ConfigProvider/config_provider'

class SmithyCli < Formula
$config_provider = ConfigProvider.new('smithy-cli')
desc "Smithy CLI - A CLI for building, validating, querying, and iterating on Smithy models"
homepage "https://smithy.io"
version $config_provider.version
desc "Smithy CLI - A CLI for building, validating, querying, and iterating on Smithy models"
homepage "https://smithy.io"


livecheck do
url :stable
strategy :github_latest
regex(/^v?(\d+(?:\.\d+)+)$/i)
end

# Default to macos-x86
platform = OS.mac? ? "darwin" : "linux"
arch = Hardware::CPU.intel? ? "x86_64" : "aarch64"

version `curl -L -s https://github.com/smithy-lang/smithy/releases/latest/download/VERSION`.strip
url "https://github.com/smithy-lang/smithy/releases/latest/download/smithy-cli-#{platform}-#{arch}.zip"
sha256 `curl -L -s https://github.com/smithy-lang/smithy/releases/latest/download/smithy-cli-#{platform}-#{arch}.zip.sha256`.split(' ').first

def install
# install everything in archive into libexec, so that
# the contents are private to homebrew, which means it won't try
# to symlink anything in this directory automatically
libexec.install Dir["*"]
# create a symlink to the private executable
bin.install_symlink "#{libexec}/bin/smithy" => "smithy"
end

def post_install
# brew relocates dylibs and assigns different ids, which is problematic since
# we package a runtime image ourselves
if OS.mac?
if Hardware::CPU.intel?
url "#{$config_provider.root_url}-darwin-x86_64.tar.gz"
sha256 $config_provider.sierra_hash
elsif Hardware::CPU.arm?
url "#{$config_provider.root_url}-darwin-aarch64.tar.gz"
sha256 $config_provider.arm64_big_sur_hash
end
elsif OS.linux?
if Hardware::CPU.intel?
url "#{$config_provider.root_url}-linux-x86_64.tar.gz"
sha256 $config_provider.linux_hash
elsif Hardware::CPU.arm?
url "#{$config_provider.root_url}-linux-aarch64.tar.gz"
sha256 $config_provider.linux_arm_hash
Dir["#{libexec}/lib/**/*.dylib"].each do |dylib|
chmod 0664, dylib
MachO::Tools.change_dylib_id(dylib, "@rpath/#{File.basename(dylib)}")
# we also need to resign the dylibs, so that their ad-hoc signatures are not invalid
MachO.codesign!(dylib)
chmod 0444, dylib
end
end
# call warmup command to generate the jsa
system "#{bin}/smithy" " warmup"
puts "Successfully installed smithy: #{`#{bin}/smithy --version`}"
end

def install
# install everything in archive into libexec, so that
# the contents are private to homebrew, which means it won't try
# to symlink anything in this directory automatically
libexec.install Dir["*"]
# create a symlink to the private executable
bin.install_symlink "#{libexec}/bin/smithy" => "smithy"
end
test do
assert_predicate lib/smithy.jsa, :exist?
assert_match version, shell_output("#{bin}/smithy --version")
assert_match "Usage: smithy", shell_output("#{bin}/smithy --help")
end

def post_install
# brew relocates dylibs and assigns different ids, which is problematic since
# we package a runtime image ourselves
if OS.mac?
Dir["#{libexec}/lib/**/*.dylib"].each do |dylib|
chmod 0664, dylib
MachO::Tools.change_dylib_id(dylib, "@rpath/#{File.basename(dylib)}")
# we also need to resign the dylibs, so that their ad-hoc signatures are not invalid
MachO.codesign!(dylib)
chmod 0444, dylib
end
end
# call warmup command to generate the jsa
system "#{bin}/#{$config_provider.bin}" " warmup"
end

test do
assert_predicate lib/"#{$config_provider.bin}.jsa", :exist?
assert_match $config_provider.version, shell_output("#{bin}/#{$config_provider.bin} --version")
assert_match "Usage: #{$config_provider.bin}", shell_output("#{bin}/#{$config_provider.bin} --help")
end
end
14 changes: 0 additions & 14 deletions bottle-configs/smithy-cli.json

This file was deleted.