-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Homebrew formula Signed-off-by: Taiki Ono <[email protected]> * Update README Signed-off-by: Taiki Ono <[email protected]> * Add update_formula script Signed-off-by: Taiki Ono <[email protected]> --------- Signed-off-by: Taiki Ono <[email protected]>
- Loading branch information
Showing
4 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,50 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'octokit' | ||
require 'open-uri' | ||
require 'digest' | ||
|
||
GITHUB_REF = ENV.fetch('GITHUB_REF') | ||
TARGET = ENV.fetch('TARGET') | ||
LOCAL = ENV.fetch('LOCAL', false) | ||
|
||
tag = GITHUB_REF.sub('refs/tags/v', '') | ||
formula_path = "HomebrewFormula/#{TARGET}.rb" | ||
repo = "Finatext/#{TARGET}" | ||
|
||
content = File.read(formula_path) | ||
|
||
updated_content = content.gsub(/version "[^"]*"/, 'version "' + tag + '"') | ||
|
||
updated_content.gsub!(/url "https:\/\/github.com\/[^"]+\/releases\/download\/[^\/]+\/([^"]+)"/) do |url| | ||
file_name = $1 | ||
new_url = "https://github.com/Finatext/gls/releases/download/v#{tag}/#{file_name}" | ||
puts "Updating #{url} to #{new_url}" | ||
%!url "#{new_url}"! | ||
end | ||
|
||
urls = updated_content.scan(/url "([^"]+)"/).flatten | ||
urls.each do |url| | ||
puts "Updating sha256 for #{url}" | ||
file = URI.open(url) | ||
sha256 = Digest::SHA256.hexdigest(file.read) | ||
updated_content.gsub!(/(url "#{Regexp.escape(url)}"\n\s*sha256 ")[^"]+"/) do |match| | ||
"#{$1}#{sha256}\"" | ||
end | ||
end | ||
|
||
if LOCAL | ||
File.write(formula_path, updated_content) | ||
else | ||
client = Octokit::Client.new(access_token: ENV.fetch('GITHUB_TOKEN')) | ||
formula_file = client.contents(repo, path: formula_path, ref: tag) | ||
|
||
client.update_contents(repo, | ||
formula_path, | ||
"Update Homebrew formula for #{tag}", | ||
formula_file.sha, | ||
updated_content, | ||
branch: 'main', | ||
file: formula_path | ||
) | ||
end |
This file contains 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 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,53 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
class Gls < Formula | ||
desc "Support gitleaks config development and extend some gitleaks features" | ||
homepage "https://github.com/Finatext/gls" | ||
version "0.1.10" | ||
license "MIT" | ||
|
||
on_macos do | ||
on_arm do | ||
url "https://github.com/Finatext/gls/releases/download/v0.1.10/gls-aarch64-apple-darwin.tar.gz" | ||
sha256 "f85e8c5c096937ea851c6f0a88fb1cf981d85d32baf6c4cbcaf29d623040e1a8" | ||
|
||
def install | ||
bin.install "gls" | ||
end | ||
end | ||
|
||
on_intel do | ||
url "https://github.com/Finatext/gls/releases/download/v0.1.10/gls-x86_64-apple-darwin.tar.gz" | ||
sha256 "959e84dabc2dd839cd69660b7185b2e870844f5719cb5bcafc2631b1d93a0319" | ||
|
||
def install | ||
bin.install "gls" | ||
end | ||
end | ||
end | ||
|
||
on_linux do | ||
on_intel do | ||
url "https://github.com/Finatext/gls/releases/download/v0.1.10/gls-x86_64-unknown-linux-gnu.tar.gz" | ||
sha256 "ac149a85f759c56ad7574c6112d219ad39d8c39a8253f3b09b4728308b4ae074" | ||
|
||
def install | ||
bin.install "gls" | ||
end | ||
end | ||
|
||
on_arm do | ||
url "https://github.com/Finatext/gls/releases/download/v0.1.10/gls-aarch64-unknown-linux-gnu.tar.gz" | ||
sha256 "d2c0fc6aefb252c9f56bbcab2e729dcb0b83a1523eae79e7e0e5f781e22a8247" | ||
|
||
def install | ||
bin.install "gls" | ||
end | ||
end | ||
end | ||
|
||
test do | ||
system "#{bin}/gls --version" | ||
end | ||
end |
This file contains 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