feat: scaffold Go module with version command, Makefile and goreleaser config
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
version: 2
|
||||
|
||||
project_name: agent-lib
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
|
||||
builds:
|
||||
- id: agent-lib
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- windows
|
||||
- linux
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
ignore:
|
||||
- goos: windows
|
||||
goarch: arm64
|
||||
ldflags:
|
||||
- -s -w -X github.com/m3tam3re/agent-lib/internal/version.Version={{.Version}}
|
||||
binary: agent-lib
|
||||
|
||||
checksum:
|
||||
name_template: "checksums.txt"
|
||||
|
||||
archives:
|
||||
- id: agent-lib
|
||||
formats: [tar.gz]
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
formats: [zip]
|
||||
|
||||
release:
|
||||
github:
|
||||
owner: m3tam3re
|
||||
name: agent-lib
|
||||
draft: false
|
||||
prerelease: auto
|
||||
mode: append
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- "^docs:"
|
||||
- "^test:"
|
||||
- "^chore:"
|
||||
- Merge pull request
|
||||
- Merge branch
|
||||
@@ -0,0 +1,26 @@
|
||||
BINARY := agent-lib
|
||||
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
||||
LDFLAGS := -s -w -X github.com/m3tam3re/agent-lib/internal/version.Version=$(VERSION)
|
||||
|
||||
.PHONY: build test vet lint fmt fmt-check clean
|
||||
|
||||
build:
|
||||
go build -ldflags '$(LDFLAGS)' -o $(BINARY) .
|
||||
|
||||
test:
|
||||
go test ./...
|
||||
|
||||
vet:
|
||||
go vet ./...
|
||||
|
||||
fmt:
|
||||
gofmt -w .
|
||||
|
||||
fmt-check:
|
||||
@out=$$(gofmt -l .); if [ -n "$$out" ]; then \
|
||||
echo "gofmt required on:"; echo "$$out"; exit 1; fi
|
||||
|
||||
lint: vet fmt-check
|
||||
|
||||
clean:
|
||||
rm -rf $(BINARY) dist/
|
||||
@@ -0,0 +1,10 @@
|
||||
module github.com/m3tam3re/agent-lib
|
||||
|
||||
go 1.26.5
|
||||
|
||||
require github.com/spf13/cobra v1.10.2
|
||||
|
||||
require (
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.9 // indirect
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
|
||||
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
|
||||
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
|
||||
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
@@ -0,0 +1,44 @@
|
||||
// Package cli wires the agent-lib command tree: vendor (curator side),
|
||||
// sync/status (client side) and version.
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"runtime"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/m3tam3re/agent-lib/internal/version"
|
||||
)
|
||||
|
||||
func NewRootCmd() *cobra.Command {
|
||||
root := &cobra.Command{
|
||||
Use: "agent-lib",
|
||||
Short: "Curated agent content: vendor external sources, sync to OpenCode",
|
||||
SilenceUsage: true,
|
||||
SilenceErrors: true,
|
||||
}
|
||||
root.AddCommand(newVersionCmd())
|
||||
return root
|
||||
}
|
||||
|
||||
func newVersionCmd() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the agent-lib version",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return printVersion(cmd.OutOrStdout())
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func printVersion(w io.Writer) error {
|
||||
_, err := fmt.Fprintf(w, "agent-lib %s (%s/%s)\n", version.Version, runtime.GOOS, runtime.GOARCH)
|
||||
return err
|
||||
}
|
||||
|
||||
func Execute() error {
|
||||
return NewRootCmd().Execute()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Package version carries the build-time version of the agent-lib binary.
|
||||
package version
|
||||
|
||||
// Version is injected at build time via
|
||||
// -ldflags "-X internal/version.Version=<version>". It defaults to "dev"
|
||||
// for plain `go build` runs.
|
||||
var Version = "dev"
|
||||
Reference in New Issue
Block a user