From 05af00386a74fd8d45f224d0c00abf047a9ed33f Mon Sep 17 00:00:00 2001 From: markkrj Date: Sun, 4 Jul 2021 17:35:15 +0800 Subject: [PATCH] Make changelog match new shipping method (#137) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I forgot about this one on !136 😅️ Also, fix #134. And I think you may close #108, as I'm writing and testing using Linuxbrew. Co-authored-by: Marcos de Oliveira Reviewed-on: https://gitea.com/gitea/homebrew-gitea/pulls/137 Reviewed-by: Andrew Thornton Reviewed-by: Lunny Xiao Co-authored-by: markkrj Co-committed-by: markkrj --- changelog.rb | 55 +++++++++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/changelog.rb b/changelog.rb index 782664e..6df00b3 100644 --- a/changelog.rb +++ b/changelog.rb @@ -1,46 +1,31 @@ -require "formula" - class Changelog < Formula + desc "Generate changelog of gitea repository" homepage "https://gitea.com/gitea/changelog" - head "https://gitea.com/gitea/changelog.git" + version "master" - stable do - version "0.1.0" - url "https://dl.gitea.io/changelog-tool/#{version}/changelog-#{version}-darwin-10.6-amd64" - sha256 `curl -s https://dl.gitea.io/changelog-tool/#{version}/changelog-#{version}-darwin-10.6-amd64.sha256`.split(" ").first - end + os = OS.mac? ? "darwin-10.6" : "linux" + arch = case Hardware::CPU.arch + when :i386 then "386" + when :x86_64 then "amd64" + when :arm64 then "arm64" + else + raise "changelog: Unsupported system architecture #{Hardware::CPU.arch}" + end - head do - url "https://dl.gitea.io/changelog-tool/master/changelog-master-darwin-10.6-amd64" - sha256 `curl -s https://dl.gitea.io/changelog-tool/master/changelog-master-darwin-10.6-amd64.sha256`.split(" ").first - version "master" - end + @@filename = "changelog-#{version}-#{os}-#{arch}" + @@url = "https://dl.gitea.io/changelog-tool/#{version}/#{@@filename}.xz" + @@sha256 = %x[ curl -sL #{@@url}.sha256 ].split.first - head do - url "https://gitea.com/gitea/changelog.git", :branch => "master" - depends_on "go" => :build + url @@url + sha256 @@sha256 + + bottle :unneeded + def install + filename = Changelog.class_variable_get("@@filename") + bin.install filename => "changelog" end test do system "#{bin}/changelog", "--version" end - - def install - case - when build.head? - mkdir_p buildpath/File.join("src", "code.gitea.io") - ln_s buildpath, buildpath/File.join("src", "code.gitea.io", "changelog") - - ENV.append_path "PATH", File.join(buildpath, "bin") - - ENV["GOPATH"] = buildpath - ENV["GOHOME"] = buildpath - - system "cd src/code.gitea.io/changelog && make build" - - bin.install "#{buildpath}/changelog" => "changelog" - else - bin.install "#{buildpath}/changelog-#{version}-darwin-10.6-amd64" => "changelog" - end - end end