dcv を homebrew-tap に対応させた
docker container の様子を見る TUI ツールである dcv というツールを作っている今日この頃。 なかなか便利になってきているのだが、インストールが面倒だった。
そこで、goreleaser の機能を利用して homebrew からインストールできるようにした。
https://zenn.dev/kou_pg_0131/articles/goreleaser-usage この記事を参考に。。
.goreleaser.yml は以下のように設定。 https://github.com/tokuhirom/dcv/blob/main/.goreleaser.yml
version: 2
before:
hooks:
- go mod tidy
builds:
- id: dcv
main: ./main.go
binary: dcv
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
- arm
goarm:
- "7"
ignore:
- goos: windows
goarch: arm64
- goos: windows
goarch: arm
archives:
- id: dcv
name_template: >-
{{- .ProjectName }}_
{{- .Os }}_
{{- .Arch }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
builds:
- dcv
checksum:
name_template: 'checksums.txt'
release:
github:
owner: tokuhirom
name: dcv
draft: false
prerelease: auto
mode: replace
name_template: "{{.ProjectName}} v{{.Version}}"
brews:
- repository:
owner: tokuhirom
name: homebrew-tap
token: "{{ .Env.TAP_GITHUB_TOKEN }}"
name: dcv
homepage: "https://github.com/tokuhirom/dcv"
description: "Docker Compose Viewer - A TUI tool for monitoring Docker Compose applications"
license: "MIT"
test: |
system "#{bin}/dcv", "--version"
install: |
bin.install "dcv"
github actions を以下のように設定した。
https://github.com/tokuhirom/dcv/blob/main/.github/workflows/release.yml
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: ~> v2
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
https://github.com/tokuhirom/homebrew-tap/ というレポジトリを用意して、Fine gained token を取得して TAP_GITHUB_TOKEN という名前で dcv の方の repository secret に設定した。
これで、あとは tag を打てば自動的に homebrew からインストール出来るようになる。 便利だね。
Published: 2025-08-12(Tue) 10:24