Skip to content

Commit

Permalink
Use goreleaser to bump Homebrew formula
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Jan 29, 2020
1 parent 739b0af commit 7a1ae75
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 27 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
env:
GH_OAUTH_CLIENT_ID: 178c6fc778ccc68e1d6a
GH_OAUTH_CLIENT_SECRET: ${{secrets.OAUTH_CLIENT_SECRET}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{secrets.UPLOAD_GITHUB_TOKEN}}
msi:
needs: goreleaser
runs-on: windows-latest
Expand Down Expand Up @@ -79,12 +79,3 @@ jobs:
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
UPLOAD_GITHUB_TOKEN: ${{secrets.UPLOAD_GITHUB_TOKEN}}
- name: Bump brew formula
if: "!contains(github.ref, '-')" # skip prereleases
uses: mislav/bump-homebrew-formula-action@v1.4
with:
formula-name: gh
homebrew-tap: github/homebrew-gh
download-url: ${{ steps.copy.outputs.asset-url }}
env:
COMMITTER_TOKEN: ${{ secrets.UPLOAD_GITHUB_TOKEN }}
70 changes: 53 additions & 17 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,65 @@ release:
before:
hooks:
- go mod tidy

builds:
- binary: bin/gh
main: ./cmd/gh
ldflags:
- -s -w -X github.com/cli/cli/command.Version={{.Version}} -X github.com/cli/cli/command.BuildDate={{time "2006-01-02"}}
- -X github.com/cli/cli/context.oauthClientID={{.Env.GH_OAUTH_CLIENT_ID}}
- -X github.com/cli/cli/context.oauthClientSecret={{.Env.GH_OAUTH_CLIENT_SECRET}}
- -X main.updaterEnabled=cli/cli
goos:
- linux
- darwin
- windows
goarch:
- amd64
- <<: &build_defaults
binary: bin/gh
main: ./cmd/gh
ldflags:
- -s -w -X github.com/cli/cli/command.Version={{.Version}} -X github.com/cli/cli/command.BuildDate={{time "2006-01-02"}}
- -X github.com/cli/cli/context.oauthClientID={{.Env.GH_OAUTH_CLIENT_ID}}
- -X github.com/cli/cli/context.oauthClientSecret={{.Env.GH_OAUTH_CLIENT_SECRET}}
- -X main.updaterEnabled=cli/cli
id: macos
goos: [darwin]
goarch: [amd64]
- <<: *build_defaults
id: linux
goos: [linux]
goarch: [386, amd64]
- <<: *build_defaults
id: windows
goos: [windows]
goarch: [386, amd64]

archives:
- name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
- id: nix
builds: [macos, linux]
<<: &archive_defaults
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
wrap_in_directory: true
replacements:
darwin: macOS
format: tar.gz
format_overrides:
- goos: windows
format: binary
- id: windows
builds: [windows]
<<: *archive_defaults
wrap_in_directory: false
format: zip

brews:
- name: gh
ids: [nix]
github:
owner: github
name: homebrew-gh
skip_upload: auto
description: GitHub CLI
homepage: https://github.com/cli/cli
custom_block: |
head do
url "https://github.com/cli/cli.git"
depends_on "go"
end
install: |
system "make" if build.head?
bin.install "bin/gh"
(bash_completion/"gh.sh").write `#{bin}/gh completion -s bash`
(zsh_completion/"_gh").write `#{bin}/gh completion -s zsh`
test: |
help_text = shell_output("#{bin}/gh --help")
assert_includes help_text, "Usage:"
nfpms:
- license: MIT
Expand Down

0 comments on commit 7a1ae75

Please sign in to comment.