From 6969ff03073118666a3521716bc9f76b16a6996e Mon Sep 17 00:00:00 2001 From: Florian Kinder Date: Sun, 12 Apr 2026 12:02:07 +0200 Subject: [PATCH 1/3] ci: migrate release pipeline to GoReleaser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the hand-rolled ~140-line bash release pipeline with GoReleaser v2, reducing the workflow to ~35 lines of YAML plus a ~65-line declarative .goreleaser.yml config. What GoReleaser now handles in a single command: - Cross-platform builds (linux/darwin/windows × amd64/arm64) - tar.gz / zip archiving - SHA256 checksums - Changelog generation from git log - GitHub Release creation with install instructions - Homebrew tap formula push to enthus-appdev/homebrew-tap This replaces the previous dawidd6/action-homebrew-bump-formula approach which failed due to two fundamental issues: 1. brew bump-formula-pr only updates the current platform's URL/SHA in multi-URL formulas (Homebrew/brew#8967 — not supported) 2. The generated bump-* branch name violated org-level branch naming rules GoReleaser avoids both: it generates the entire formula from scratch and pushes directly to the tap's main branch. Note: GoReleaser v2 deprecates `brews` in favor of `homebrew_casks`. Casks are the correct Homebrew format for precompiled binaries, but currently macOS-only — no Linux Homebrew support. Keeping `brews` for now to maintain cross-platform coverage. Revisit when the ecosystem evolves. --- .github/workflows/release.yml | 142 +++------------------------------- .goreleaser.yml | 68 ++++++++++++++++ 2 files changed, 77 insertions(+), 133 deletions(-) create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 06264d0..d1ac3e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,121 +27,7 @@ jobs: - name: Run tests run: go test -v -race ./... - - name: Build binaries - run: | - VERSION=${GITHUB_REF_NAME} - COMMIT=$(git rev-parse --short HEAD) - DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") - LDFLAGS="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" - - mkdir -p dist - - # Build for each platform - platforms=( - "linux/amd64" - "linux/arm64" - "darwin/amd64" - "darwin/arm64" - "windows/amd64" - "windows/arm64" - ) - - for platform in "${platforms[@]}"; do - GOOS=${platform%/*} - GOARCH=${platform#*/} - - output_name="esq-${GOOS}-${GOARCH}" - if [ "$GOOS" = "windows" ]; then - output_name+=".exe" - fi - - echo "Building $output_name..." - GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "${LDFLAGS}" -o "dist/${output_name}" ./cmd/esq - done - - # Create archives - cd dist - for file in esq-*; do - if [[ "$file" == *.exe ]]; then - zip "${file%.exe}.zip" "$file" - rm "$file" - else - tar czf "${file}.tar.gz" "$file" - rm "$file" - fi - done - - # Generate checksums - sha256sum * > checksums.txt - - - name: Generate changelog - id: changelog - run: | - # Get previous tag - PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") - - if [ -n "$PREV_TAG" ]; then - echo "Generating changelog from $PREV_TAG to $GITHUB_REF_NAME" - CHANGELOG=$(git log --pretty=format:"- %s (%h)" "$PREV_TAG".."$GITHUB_REF_NAME" --no-merges) - else - echo "No previous tag found, including all commits" - CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges) - fi - - # Escape for GitHub Actions - echo "changelog<> $GITHUB_OUTPUT - echo "$CHANGELOG" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Create Release - uses: softprops/action-gh-release@v2 - with: - name: ${{ github.ref_name }} - body: | - ## What's Changed - - ${{ steps.changelog.outputs.changelog }} - - ## Installation - - ### Homebrew (macOS and Linux) - ```bash - brew install enthus-appdev/tap/esq - ``` - - ### macOS (Apple Silicon) - ```bash - curl -L https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/esq-darwin-arm64.tar.gz | tar xz - chmod +x esq-darwin-arm64 - sudo mv esq-darwin-arm64 /usr/local/bin/esq - ``` - - ### macOS (Intel) - ```bash - curl -L https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/esq-darwin-amd64.tar.gz | tar xz - chmod +x esq-darwin-amd64 - sudo mv esq-darwin-amd64 /usr/local/bin/esq - ``` - - ### Linux (x64) - ```bash - curl -L https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/esq-linux-amd64.tar.gz | tar xz - chmod +x esq-linux-amd64 - sudo mv esq-linux-amd64 /usr/local/bin/esq - ``` - - ### Windows - Download `esq-windows-amd64.zip` and add to your PATH. - - ## Checksums - - See `checksums.txt` for SHA256 checksums of all binaries. - files: | - dist/* - draft: false - prerelease: ${{ contains(github.ref_name, '-') }} - - - name: Generate GitHub App token for tap bump + - name: Generate GitHub App token for tap id: app-token uses: actions/create-github-app-token@v2 with: @@ -150,22 +36,12 @@ jobs: owner: enthus-appdev repositories: homebrew-tap - - name: Get GitHub App user ID - id: app-user - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: | - USER_ID=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id) - echo "user-id=$USER_ID" >> "$GITHUB_OUTPUT" - - - name: Bump Homebrew tap formula - uses: dawidd6/action-homebrew-bump-formula@v7 - continue-on-error: true + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 with: - token: ${{ steps.app-token.outputs.token }} - no_fork: true - tap: enthus-appdev/homebrew-tap - formula: esq - tag: ${{ github.ref_name }} - user_name: ${{ steps.app-token.outputs.app-slug }}[bot] - user_email: ${{ steps.app-user.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com + distribution: goreleaser + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HOMEBREW_TAP_TOKEN: ${{ steps.app-token.outputs.token }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..bb7465a --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,68 @@ +version: 2 + +project_name: esq + +builds: + - main: ./cmd/esq + binary: esq + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + ldflags: + - -s -w + - -X main.version={{.Version}} + - -X main.commit={{.ShortCommit}} + +archives: + - formats: + - tar.gz + format_overrides: + - goos: windows + formats: + - zip + +checksum: + name_template: checksums.txt + +changelog: + sort: asc + +release: + github: + owner: enthus-appdev + name: esq-cli + header: | + ## Installation + + ### Homebrew (macOS and Linux) + ```bash + brew install enthus-appdev/tap/esq + ``` + + ### Binary download + Download the archive for your platform below, extract, and add to your PATH. + +brews: + - name: esq + repository: + owner: enthus-appdev + name: homebrew-tap + token: "{{ .Env.HOMEBREW_TAP_TOKEN }}" + directory: Formula + homepage: https://github.com/enthus-appdev/esq-cli + description: "Query and inspect Elasticsearch clusters across multiple environments" + license: MIT + commit_author: + name: enthus-appdev-tap-bumper[bot] + email: 275364917+enthus-appdev-tap-bumper[bot]@users.noreply.github.com + commit_msg_template: "chore(formula): bump {{ .ProjectName }} to {{ .Tag }}" + test: | + assert_match version.to_s, shell_output("#{bin}/esq --version") + install: | + bin.install "esq" From eb080f99499acc1f69fc6e36ae210ea0cafc8520 Mon Sep 17 00:00:00 2001 From: Florian Kinder Date: Sun, 12 Apr 2026 12:05:57 +0200 Subject: [PATCH 2/3] fix: use homebrews instead of deprecated brews key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GoReleaser v2 renamed brews → homebrews (the direct successor for CLI formula generation, supporting both macOS and Linux). The homebrew_casks key is a separate thing for macOS-only Casks — not what we need. --- .goreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index bb7465a..be65101 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -48,7 +48,7 @@ release: ### Binary download Download the archive for your platform below, extract, and add to your PATH. -brews: +homebrews: - name: esq repository: owner: enthus-appdev From eadaa215569c5062c6862e315a9223aa08ae0697 Mon Sep 17 00:00:00 2001 From: Florian Kinder Date: Sun, 12 Apr 2026 12:06:49 +0200 Subject: [PATCH 3/3] revert: go back to brews key (homebrews does not exist) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous commit changed brews → homebrews based on a review suggestion, but homebrews is not a valid GoReleaser v2 key (config validation fails). homebrew_casks exists but has a different config structure (no test/install blocks — it generates actual macOS Casks, not formulas). brews is the only key that works today. The deprecation warning is acknowledged — when GoReleaser provides a formula-compatible successor, we migrate then. --- .goreleaser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index be65101..bb7465a 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -48,7 +48,7 @@ release: ### Binary download Download the archive for your platform below, extract, and add to your PATH. -homebrews: +brews: - name: esq repository: owner: enthus-appdev