diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b4cc5a..965f632 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,15 +23,15 @@ jobs: go-version: '1.25' # Ensure this matches your project's Go version cache: true - - name: Build all architectures - run: make release - - - name: Create GitHub Release and Upload Assets - uses: softprops/action-gh-release@v2 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 with: - files: build/* + distribution: goreleaser + version: '~> v2' + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} docker-release: runs-on: ubuntu-latest diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..49b497a --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,78 @@ +version: 2 +project_name: amqcli + +before: + hooks: + - go mod tidy + +builds: + - id: amqcli + main: ./cmd/main.go + binary: amqcli + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + ldflags: + - -s -w -X main.Version={{.Version}} + + - id: amqcli-aix + main: ./cmd/main.go + binary: amqcli + env: + - CGO_ENABLED=0 + - GOPPC64=power8 + goos: + - aix + goarch: + - ppc64 + ldflags: + - -w -X main.Version={{.Version}} + +archives: + - format: tar.gz + name_template: >- + {{ .ProjectName }}_{{ .Os }}_{{ .Arch }} + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: "{{ incpatch .Version }}-next" + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +brews: + - name: amqcli + repository: + owner: xvlet + name: homebrew-amqcli + token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" + + commit_author: + name: goreleaserbot + email: bot@goreleaser.com + + directory: Formula + + homepage: "https://github.com/xvlet/amqcli" + description: "ActiveMQ TUI Client - Manage and monitor ActiveMQ queues and messages via terminal" + + install: | + bin.install "amqcli" + + test: | + system "#{bin}/amqcli", "--version" diff --git a/cmd/main.go b/cmd/main.go index 36ad72b..7e1b1e2 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "log" "github.com/xvlet/amqcli/adapter/inbound/ui" @@ -13,10 +14,20 @@ import ( tea "github.com/charmbracelet/bubbletea" ) +var ( + Version = "dev" +) + func main() { env := flag.String("env", "dev", "Environment profile to use (e.g. dev, prod)") + showVersion := flag.Bool("version", false, "Print application version") flag.Parse() + if *showVersion { + fmt.Printf("amqcli version %s\n", Version) + return + } + // 1. Load config cfg, err := config.LoadConfig("config.yml") if err != nil {