From f9ebb4bf2587d7cccbf672f0ffaeffcf9b0f183f Mon Sep 17 00:00:00 2001 From: sneak Date: Fri, 1 May 2026 07:07:23 +0200 Subject: [PATCH] Add release process via goreleaser, restructure Make targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make targets each do one thing now: lint, fmt, fmt-check, test. Use 'make check' for combined lint + fmt-check + test (the standard pre-commit gate). Release builds are pure-Go (CGO_ENABLED=0) cross-compiling to linux/darwin × amd64/arm64. --- .goreleaser.yaml | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 35 +++++++++++++++++++----------- 2 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..899223d --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,55 @@ +version: 2 + +project_name: vaultik + +before: + hooks: + - go mod tidy + +builds: + - id: vaultik + main: ./cmd/vaultik + binary: vaultik + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 + ldflags: + - -s -w + - -X 'git.eeqj.de/sneak/vaultik/internal/globals.Version={{ .Version }}' + - -X 'git.eeqj.de/sneak/vaultik/internal/globals.Commit={{ .Commit }}' + +archives: + - id: default + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + formats: + - tar.gz + files: + - LICENSE + - README.md + +checksum: + name_template: "checksums.txt" + algorithm: sha256 + +snapshot: + version_template: "{{ incpatch .Version }}-next" + +changelog: + sort: asc + use: git + filters: + exclude: + - "^docs:" + - "^test:" + - "^chore:" + - "Merge pull request" + - "Merge branch" + +release: + draft: true + prerelease: auto diff --git a/Makefile b/Makefile index 223ce8d..b84c13c 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -.PHONY: test fmt lint build clean all +.PHONY: all check test lint fmt fmt-check build clean deps test-coverage test-integration local install release release-snapshot # Version number -VERSION := 0.0.1 +VERSION := 1.0.0-rc.1 # Build variables GIT_REVISION := $(shell git rev-parse HEAD 2>/dev/null || echo "unknown") @@ -13,8 +13,11 @@ LDFLAGS := -X 'git.eeqj.de/sneak/vaultik/internal/globals.Version=$(VERSION)' \ # Default target all: vaultik -# Run tests -test: lint fmt-check +# Combined pre-commit/CI gate: lint, format check, then tests. +check: lint fmt-check test + +# Run tests only. +test: @echo "Running tests..." @if ! go test -v -timeout 10s ./... 2>&1; then \ echo ""; \ @@ -23,41 +26,41 @@ test: lint fmt-check exit 1; \ fi -# Check if code is formatted +# Check if code is formatted. fmt-check: @if [ -n "$$(go fmt ./...)" ]; then \ echo "Error: Code is not formatted. Run 'make fmt' to fix."; \ exit 1; \ fi -# Format code +# Format code. fmt: go fmt ./... -# Run linter +# Run linter only. lint: golangci-lint run -# Build binary +# Build binary. vaultik: internal/*/*.go cmd/vaultik/*.go go build -ldflags "$(LDFLAGS)" -o $@ ./cmd/vaultik -# Clean build artifacts +# Clean build artifacts. clean: rm -f vaultik go clean -# Install dependencies +# Install dependencies. deps: go mod download go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest -# Run tests with coverage +# Run tests with coverage. test-coverage: go test -v -coverprofile=coverage.out ./... go tool cover -html=coverage.out -o coverage.html -# Run integration tests +# Run integration tests. test-integration: go test -v -tags=integration ./... @@ -67,3 +70,11 @@ local: install: vaultik cp ./vaultik $(HOME)/bin/ + +# Build and publish release artifacts (linux/darwin × amd64/arm64) via goreleaser. +release: + goreleaser release --clean + +# Dry-run a release build without publishing or tagging. +release-snapshot: + goreleaser release --clean --snapshot