From e7e353daec9293d7ac3ecf95aedc4cdb2e4dacd5 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Mon, 23 Mar 2026 22:14:38 -0700 Subject: [PATCH] Add goreleaser config and version command for v0.1.0. GoReleaser builds static binaries for linux/darwin on amd64/arm64, injecting version via ldflags. Version command prints the embedded version (defaults to "dev" for local builds). Co-Authored-By: Claude Opus 4.6 (1M context) --- .goreleaser.yaml | 40 ++++++++++++++++++++++++++++++++++++++++ cmd/sgard/version.go | 21 +++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .goreleaser.yaml create mode 100644 cmd/sgard/version.go diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..c7d7b17 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,40 @@ +version: 2 + +before: + hooks: + - go mod tidy + +builds: + - main: ./cmd/sgard + env: + - CGO_ENABLED=0 + ldflags: + - -s -w -X main.version={{.Version}} + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + +archives: + - formats: [binary] + name_template: >- + {{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{- if .Arm }}v{{ .Arm }}{{ end }}_v{{ .Version }} + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +release: + github: + owner: kisom + name: sgard + footer: >- + + --- + + Released by [GoReleaser](https://github.com/goreleaser/goreleaser). diff --git a/cmd/sgard/version.go b/cmd/sgard/version.go new file mode 100644 index 0000000..abe9a1b --- /dev/null +++ b/cmd/sgard/version.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +var version = "dev" + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print the version", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println(version) + }, +} + +func init() { + rootCmd.AddCommand(versionCmd) +}