Skip to content

Commit 7a8c7c4

Browse files
fengyilyclaude
andcommitted
Add GoReleaser config and Homebrew tap support
Replace manual build matrix CI with GoReleaser for automated multi-platform releases and Homebrew formula publishing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c5a8f5c commit 7a8c7c4

2 files changed

Lines changed: 71 additions & 90 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 15 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build & Release
1+
name: Release
22

33
on:
44
push:
@@ -15,103 +15,28 @@ permissions:
1515
contents: write
1616

1717
jobs:
18-
build:
19-
name: Build ${{ matrix.os }}/${{ matrix.arch }}
18+
release:
19+
name: GoReleaser
2020
runs-on: ubuntu-latest
21-
strategy:
22-
matrix:
23-
include:
24-
# Linux
25-
- { goos: linux, goarch: amd64, os: linux, arch: amd64, ext: "" }
26-
- { goos: linux, goarch: arm64, os: linux, arch: arm64, ext: "" }
27-
- { goos: linux, goarch: "386", os: linux, arch: "386", ext: "" }
28-
- { goos: linux, goarch: arm, os: linux, arch: armv7, ext: "", goarm: "7" }
29-
# macOS
30-
- { goos: darwin, goarch: amd64, os: darwin, arch: amd64, ext: "" }
31-
- { goos: darwin, goarch: arm64, os: darwin, arch: arm64, ext: "" }
32-
# Windows
33-
- { goos: windows, goarch: amd64, os: windows, arch: amd64, ext: ".exe" }
34-
- { goos: windows, goarch: arm64, os: windows, arch: arm64, ext: ".exe" }
35-
- { goos: windows, goarch: "386", os: windows, arch: "386", ext: ".exe" }
36-
3721
steps:
3822
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
3925

4026
- name: Set up Go
4127
uses: actions/setup-go@v5
4228
with:
43-
go-version: "1.21"
44-
45-
- name: Resolve version tag
46-
id: version
47-
run: |
48-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
49-
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
50-
else
51-
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
52-
fi
29+
go-version: "1.25"
5330

54-
- name: Build binary
55-
env:
56-
GOOS: ${{ matrix.goos }}
57-
GOARCH: ${{ matrix.goarch }}
58-
GOARM: ${{ matrix.goarm }}
59-
CGO_ENABLED: "0"
31+
- name: Create tag for workflow_dispatch
32+
if: github.event_name == 'workflow_dispatch'
6033
run: |
61-
VERSION="${{ steps.version.outputs.tag }}"
62-
COMMIT="${{ github.sha }}"
63-
BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
64-
LDFLAGS="-s -w -X shield-cli/cmd.Version=${VERSION} -X shield-cli/cmd.GitCommit=${COMMIT} -X shield-cli/cmd.BuildTime=${BUILD_TIME}"
65-
66-
BINARY_NAME="shield-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }}"
67-
go build -trimpath -ldflags "${LDFLAGS}" -o "${BINARY_NAME}" .
68-
69-
# Create archive
70-
if [ "${{ matrix.goos }}" = "windows" ]; then
71-
zip "${BINARY_NAME%.exe}.zip" "${BINARY_NAME}"
72-
else
73-
tar czf "${BINARY_NAME}.tar.gz" "${BINARY_NAME}"
74-
fi
34+
git tag ${{ inputs.tag }}
7535
76-
- name: Upload artifact
77-
uses: actions/upload-artifact@v4
36+
- name: Run GoReleaser
37+
uses: goreleaser/goreleaser-action@v6
7838
with:
79-
name: shield-${{ matrix.os }}-${{ matrix.arch }}
80-
path: |
81-
shield-*.tar.gz
82-
shield-*.zip
83-
84-
release:
85-
name: Create Release
86-
needs: build
87-
runs-on: ubuntu-latest
88-
steps:
89-
- name: Download all artifacts
90-
uses: actions/download-artifact@v4
91-
with:
92-
path: dist
93-
merge-multiple: true
94-
95-
- name: Resolve version tag
96-
id: version
97-
run: |
98-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
99-
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
100-
else
101-
echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
102-
fi
103-
104-
- name: Generate checksums
105-
working-directory: dist
106-
run: sha256sum shield-* > checksums.txt
107-
108-
- name: Create GitHub Release
109-
uses: softprops/action-gh-release@v2
110-
with:
111-
tag_name: ${{ steps.version.outputs.tag }}
112-
name: Shield CLI ${{ steps.version.outputs.tag }}
113-
generate_release_notes: true
114-
files: |
115-
dist/shield-*.tar.gz
116-
dist/shield-*.zip
117-
dist/checksums.txt
39+
version: latest
40+
args: release --clean
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}

‎.goreleaser.yaml‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
project_name: shield-cli
2+
3+
builds:
4+
- main: .
5+
binary: shield
6+
env:
7+
- CGO_ENABLED=0
8+
goos:
9+
- darwin
10+
- linux
11+
- windows
12+
goarch:
13+
- amd64
14+
- arm64
15+
- "386"
16+
goarm:
17+
- "7"
18+
ignore:
19+
- goos: darwin
20+
goarch: "386"
21+
- goos: windows
22+
goarch: arm
23+
ldflags:
24+
- -s -w
25+
- -X shield-cli/cmd.Version={{.Version}}
26+
- -X shield-cli/cmd.GitCommit={{.Commit}}
27+
- -X shield-cli/cmd.BuildTime={{.Date}}
28+
29+
archives:
30+
- format: tar.gz
31+
name_template: "shield-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
32+
format_overrides:
33+
- goos: windows
34+
format: zip
35+
36+
brews:
37+
- repository:
38+
owner: fengyily
39+
name: homebrew-tap
40+
homepage: "https://github.com/fengyily/sheild-cli"
41+
description: "Shield CLI - Secure Tunnel Connector"
42+
license: "MIT"
43+
install: |
44+
bin.install "shield"
45+
test: |
46+
system "#{bin}/shield", "--help"
47+
48+
checksum:
49+
name_template: "checksums.txt"
50+
51+
changelog:
52+
sort: asc
53+
filters:
54+
exclude:
55+
- "^docs:"
56+
- "^test:"

0 commit comments

Comments
 (0)