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) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 22:14:38 -07:00
parent 6dc84598de
commit e7e353daec
2 changed files with 61 additions and 0 deletions

40
.goreleaser.yaml Normal file
View File

@@ -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).

21
cmd/sgard/version.go Normal file
View File

@@ -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)
}