From e33904d0368ca1d0df87b171d912de3a4021a777 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 23 May 2024 13:09:59 -0400 Subject: [PATCH] goreleaser: refactor brew formula Fixes #1909 --- .goreleaser.yml | 91 +++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 60 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 156f5734c1..e9f7f1ab40 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -74,67 +74,38 @@ snapcrafts: - "network" brews: - name: "{{.ProjectName}}" - repository: - owner: "authzed" - name: "homebrew-tap" - token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" - url_template: "https://github.com/authzed/spicedb/releases/download/{{ .Tag }}/{{ .ArtifactName }}" - download_strategy: "CurlDownloadStrategy" - commit_author: - name: "authzedbot" - email: "infrastructure@authzed.com" - commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}" - homepage: "https://authzed.com/" - description: "SpiceDB is a Zanzibar-inspired database that stores, computes, and validates application permissions." - license: "Apache-2.0" - directory: "Formula" - skip_upload: "auto" - custom_block: | - head "https://github.com/authzed/spicedb.git", :branch => "main" - dependencies: - - name: "go" - type: "build" - test: | - system "#{bin}/spicedb version" - install: | - if !File.exists? "spicedb" - system "go build --ldflags \"-s -w -X github.com/jzelinskie/cobrautil/v2.Version=$(git describe --always --abbrev=7 --dirty --tags)\" ./cmd/spicedb" - end - bin.install "spicedb" - (bash_completion/"spicedb").write Utils.safe_popen_read("#{bin}/spicedb", "completion", "bash") - (zsh_completion/"_spicedb").write Utils.safe_popen_read("#{bin}/spicedb", "completion", "zsh") - (fish_completion/"spicedb.fish").write Utils.safe_popen_read("#{bin}/spicedb", "completion", "fish") + <<: &brew-shared + description: "Google Zanzibar-inspired permissions database for fine-grained access control" + homepage: "https://github.com/authzed/spicedb" + license: "Apache-2.0" + dependencies: + - name: "go" + type: "build" + custom_block: | + head "https://github.com/authzed/spicedb.git", :branch => "main" + url_template: "https://github.com/authzed/spicedb/releases/download/{{ .Tag }}/{{ .ArtifactName }}" + install: | + unless File.exist? "spicedb" + versionVar = "github.com/jzelinskie/cobrautil/v2.Version" + versionCmd = "$(git describe --always --abbrev=7 --dirty --tags)" + system "go build --ldflags '-s -w -X #{versionVar}=#{versionCmd}' ./cmd/spicedb" + end + bin.install "spicedb" + generate_completions_from_executable(bin/"spicedb", "completion", shells: [:bash, :zsh, :fish]) + test: | + system "#{bin}/spicedb version" + repository: + owner: "authzed" + name: "homebrew-tap" + token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" + commit_author: + name: "authzedbot" + email: "infrastructure@authzed.com" + commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}" + directory: "Formula" + skip_upload: "auto" - name: "{{.ProjectName}}@{{.Version}}" - repository: - owner: "authzed" - name: "homebrew-tap" - token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" - url_template: "https://github.com/authzed/spicedb/releases/download/{{ .Tag }}/{{ .ArtifactName }}" - download_strategy: "CurlDownloadStrategy" - commit_author: - name: "authzedbot" - email: "infrastructure@authzed.com" - commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}" - homepage: "https://authzed.com/" - description: "SpiceDB is a Zanzibar-inspired database that stores, computes, and validates application permissions." - license: "Apache-2.0" - directory: "Formula" - skip_upload: "auto" - custom_block: | - head "https://github.com/authzed/spicedb.git", :branch => "main" - dependencies: - - name: "go" - type: "build" - test: | - system "#{bin}/spicedb version" - install: | - if !File.exists? "spicedb" - system "go build --ldflags \"-s -w -X github.com/jzelinskie/cobrautil/v2.Version=$(git describe --always --abbrev=7 --dirty --tags)\" ./cmd/spicedb" - end - bin.install "spicedb" - bash_completion.install "completions/spicedb.bash" => "spicedb" - zsh_completion.install "completions/spicedb.zsh" => "_spicedb" - fish_completion.install "completions/spicedb.fish" + <<: *brew-shared dockers: # AMD64 - image_templates: