-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add meshix-cli formula #4
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b5c04b7
feat: add meshix-cli formula
anand-testcompare 39e9636
fix: use authenticated meshix formula updates
anand-testcompare 82f89a6
fix: skip meshix formula bumps without release access
anand-testcompare fdbe4af
fix: make meshix formula validation deterministic
anand-testcompare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| class MeshixCliGitHubReleaseDownloadStrategy < CurlDownloadStrategy | ||
| def initialize(url, name, version, **meta) | ||
| @resolved_basename = meta.delete(:resolved_basename) | ||
| @github_token = resolve_github_token | ||
|
|
||
| if @github_token.nil? || @github_token.empty? | ||
| raise CurlDownloadStrategyError.new( | ||
| url, | ||
| [ | ||
| "GitHub authentication is required to download the private meshix-cli release asset.", | ||
| "Set HOMEBREW_GITHUB_API_TOKEN, GH_TOKEN, GITHUB_TOKEN, or SHPIT_GH_TOKEN,", | ||
| "or log in with gh auth login." | ||
| ].join(" ") | ||
| ) | ||
| end | ||
|
|
||
| meta[:headers] ||= [] | ||
| meta[:headers] << "Accept: application/octet-stream" | ||
| meta[:headers] << "Authorization: Bearer #{@github_token}" | ||
| super | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def resolve_github_token | ||
| %w[HOMEBREW_GITHUB_API_TOKEN GH_TOKEN GITHUB_TOKEN SHPIT_GH_TOKEN].each do |key| | ||
| value = ENV[key]&.strip | ||
| return value unless value.nil? || value.empty? | ||
| end | ||
|
|
||
| [ | ||
| "#{HOMEBREW_PREFIX}/bin/gh", | ||
| "/opt/homebrew/bin/gh", | ||
| "/usr/local/bin/gh", | ||
| "gh" | ||
| ].uniq.each do |gh| | ||
| next if gh != "gh" && !File.executable?(gh) | ||
|
|
||
| value = Utils.safe_popen_read(gh, "auth", "token").strip | ||
| return value unless value.empty? | ||
| rescue ErrorDuringExecution, Errno::ENOENT | ||
| next | ||
| end | ||
|
|
||
| nil | ||
| end | ||
|
|
||
| def resolve_url_basename_time_file_size(url, timeout: nil) | ||
| resolved_url, _, last_modified, file_size, content_type, is_redirection = super | ||
| [resolved_url, @resolved_basename, last_modified, file_size, content_type, is_redirection] | ||
| end | ||
|
|
||
| def curl_output(*args, **options) | ||
| super(*args, secrets: [@github_token], **options) | ||
| end | ||
|
|
||
| def curl(*args, print_stdout: true, **options) | ||
| super(*args, print_stdout: print_stdout, secrets: [@github_token], **options) | ||
| end | ||
| end | ||
|
|
||
| class MeshixCli < Formula | ||
| desc "Meshix CLI for run inspection and generation workflows" | ||
| homepage "https://github.com/shpitdev/meshix-observability" | ||
| version "0.0.1" | ||
| license :cannot_represent | ||
| depends_on arch: :arm64 | ||
|
|
||
| on_macos do | ||
| on_arm do | ||
| url "https://api.github.com/repos/shpitdev/meshix-observability/releases/assets/391763692", | ||
| using: MeshixCliGitHubReleaseDownloadStrategy, | ||
| resolved_basename: "meshix-cli_v0.0.1_darwin_arm64.tar.gz" | ||
| sha256 "01e42197ff960a8f6033f80178800f8ede31bb8e18e276f705abc72b17ba7426" | ||
| end | ||
| end | ||
|
|
||
| def install | ||
| bin.install "meshix-cli" | ||
| end | ||
|
|
||
| def caveats | ||
| <<~EOS | ||
| Package-manager installs provide the stable meshix-cli command only. | ||
| Start with: | ||
| meshix-cli --help | ||
|
|
||
| For a checkout-linked dev command, install meshix-cli-dev from a local checkout. | ||
| EOS | ||
| end | ||
|
|
||
| test do | ||
| output = shell_output("#{bin}/meshix-cli --help") | ||
| assert_match "meshix-cli", output | ||
| assert_match "architecture", output | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.