Skip to content

Commit 7a1ae75

Browse files
committed
Use goreleaser to bump Homebrew formula
1 parent 739b0af commit 7a1ae75

File tree

2 files changed

+54
-27
lines changed

2 files changed

+54
-27
lines changed

.github/workflows/releases.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
env:
2626
GH_OAUTH_CLIENT_ID: 178c6fc778ccc68e1d6a
2727
GH_OAUTH_CLIENT_SECRET: ${{secrets.OAUTH_CLIENT_SECRET}}
28-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
28+
GITHUB_TOKEN: ${{secrets.UPLOAD_GITHUB_TOKEN}}
2929
msi:
3030
needs: goreleaser
3131
runs-on: windows-latest
@@ -79,12 +79,3 @@ jobs:
7979
env:
8080
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
8181
UPLOAD_GITHUB_TOKEN: ${{secrets.UPLOAD_GITHUB_TOKEN}}
82-
- name: Bump brew formula
83-
if: "!contains(github.ref, '-')" # skip prereleases
84-
uses: mislav/bump-homebrew-formula-action@v1.4
85-
with:
86-
formula-name: gh
87-
homebrew-tap: github/homebrew-gh
88-
download-url: ${{ steps.copy.outputs.asset-url }}
89-
env:
90-
COMMITTER_TOKEN: ${{ secrets.UPLOAD_GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,65 @@ release:
66
before:
77
hooks:
88
- go mod tidy
9+
910
builds:
10-
- binary: bin/gh
11-
main: ./cmd/gh
12-
ldflags:
13-
- -s -w -X github.com/cli/cli/command.Version={{.Version}} -X github.com/cli/cli/command.BuildDate={{time "2006-01-02"}}
14-
- -X github.com/cli/cli/context.oauthClientID={{.Env.GH_OAUTH_CLIENT_ID}}
15-
- -X github.com/cli/cli/context.oauthClientSecret={{.Env.GH_OAUTH_CLIENT_SECRET}}
16-
- -X main.updaterEnabled=cli/cli
17-
goos:
18-
- linux
19-
- darwin
20-
- windows
21-
goarch:
22-
- amd64
11+
- <<: &build_defaults
12+
binary: bin/gh
13+
main: ./cmd/gh
14+
ldflags:
15+
- -s -w -X github.com/cli/cli/command.Version={{.Version}} -X github.com/cli/cli/command.BuildDate={{time "2006-01-02"}}
16+
- -X github.com/cli/cli/context.oauthClientID={{.Env.GH_OAUTH_CLIENT_ID}}
17+
- -X github.com/cli/cli/context.oauthClientSecret={{.Env.GH_OAUTH_CLIENT_SECRET}}
18+
- -X main.updaterEnabled=cli/cli
19+
id: macos
20+
goos: [darwin]
21+
goarch: [amd64]
22+
- <<: *build_defaults
23+
id: linux
24+
goos: [linux]
25+
goarch: [386, amd64]
26+
- <<: *build_defaults
27+
id: windows
28+
goos: [windows]
29+
goarch: [386, amd64]
30+
2331
archives:
24-
- name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
32+
- id: nix
33+
builds: [macos, linux]
34+
<<: &archive_defaults
35+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
2536
wrap_in_directory: true
2637
replacements:
2738
darwin: macOS
2839
format: tar.gz
29-
format_overrides:
30-
- goos: windows
31-
format: binary
40+
- id: windows
41+
builds: [windows]
42+
<<: *archive_defaults
43+
wrap_in_directory: false
44+
format: zip
45+
46+
brews:
47+
- name: gh
48+
ids: [nix]
49+
github:
50+
owner: github
51+
name: homebrew-gh
52+
skip_upload: auto
53+
description: GitHub CLI
54+
homepage: https://github.com/cli/cli
55+
custom_block: |
56+
head do
57+
url "https://github.com/cli/cli.git"
58+
depends_on "go"
59+
end
60+
install: |
61+
system "make" if build.head?
62+
bin.install "bin/gh"
63+
(bash_completion/"gh.sh").write `#{bin}/gh completion -s bash`
64+
(zsh_completion/"_gh").write `#{bin}/gh completion -s zsh`
65+
test: |
66+
help_text = shell_output("#{bin}/gh --help")
67+
assert_includes help_text, "Usage:"
3268
3369
nfpms:
3470
- license: MIT

0 commit comments

Comments
 (0)