Skip to content

Commit ad9e541

Browse files
authored
Update release process (#206)
* Align release process with acor project - Upgrade GoReleaser to v2 config format (dockers → dockers_v2) - Enable changelog generation (was skipped) - Add non-root user to Dockerfile.goreleaser with multi-platform support - Add release-drafter workflow and config for automated release notes - Extend Makefile with vet, coverage, race, lint-fix targets * Fix duplicate govet key in golangci-lint config * Address code review feedback - Revert dockers_v2 back to dockers (top-level key unchanged in GoReleaser v2) - Move breaking_changes to major version-resolver for correct semver * Keep breaking_changes under minor with explanatory comment Pre-1.0 project uses minor bumps for breaking changes intentionally. * Disable fieldalignment to restore original lint behavior The duplicate govet key merge accidentally activated fieldalignment, which fails on pre-existing struct layouts outside this PR's scope.
1 parent db8a516 commit ad9e541

7 files changed

Lines changed: 108 additions & 30 deletions

File tree

.github/release-drafter.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name-template: "v$RESOLVED_VERSION"
2+
tag-template: "v$RESOLVED_VERSION"
3+
template: |
4+
## What's Changed
5+
6+
$CHANGES
7+
8+
categories:
9+
- title: "Breaking Changes"
10+
labels:
11+
- "breaking_changes"
12+
- title: "New Features"
13+
labels:
14+
- "feature_request"
15+
- "enhancement"
16+
- title: "Bug Fixes"
17+
labels:
18+
- "bug"
19+
- title: "Documentation"
20+
labels:
21+
- "documentation"
22+
- title: "Dependencies"
23+
labels:
24+
- "dependencies"
25+
- title: "Maintenance"
26+
labels:
27+
- "maintenance"
28+
- "github_actions"
29+
30+
version-resolver:
31+
minor:
32+
labels:
33+
- "breaking_changes" # intentionally minor: project is pre-1.0
34+
- "feature_request"
35+
- "enhancement"
36+
patch:
37+
labels:
38+
- "bug"
39+
- "documentation"
40+
- "dependencies"
41+
- "maintenance"
42+
43+
change-template: "- $TITLE (#$NUMBER) @$AUTHOR"
44+
no-changes-template: "- No changes"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
update-release-draft:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: release-drafter/release-drafter@v6
17+
with:
18+
config-name: release-drafter.yml
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.golangci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ linters-settings:
3333
check-shadowing: true
3434
lll:
3535
line-length: 120
36-
govet:
37-
enable:
38-
- fieldalignment
3936
misspell:
4037
locale: US
4138

.goreleaser.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version: 2
2+
13
project_name: kvs
24

35
env:
@@ -44,11 +46,9 @@ archives:
4446
- README.md
4547
- CHANGELOG.md
4648
- CODE_OF_CONDUCT.md
47-
- CONTRIBUTING.md
48-
- SECURITY.md
4949

5050
changelog:
51-
skip: true
51+
disable: false
5252

5353
checksum:
5454
algorithm: sha256
@@ -77,25 +77,30 @@ brews:
7777
skip_upload: false
7878

7979
dockers:
80-
- ids:
81-
- kvs
80+
- images:
81+
- ghcr.io/skyoo2003/kvs
8282
dockerfile: Dockerfile.goreleaser
83-
use_buildx: true
84-
image_templates:
85-
- "ghcr.io/skyoo2003/kvs:{{ .Tag }}-alpine"
86-
- "ghcr.io/skyoo2003/kvs:v{{ .Major }}.{{ .Minor }}-alpine"
87-
- "ghcr.io/skyoo2003/kvs:v{{ .Major }}-alpine"
88-
- "ghcr.io/skyoo2003/kvs:latest-alpine"
89-
build_flag_templates:
90-
- "--label=org.opencontainers.image.created={{ .Date }}"
91-
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
92-
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
93-
- "--label=org.opencontainers.image.version={{ .Version }}"
94-
skip_push: false
83+
ids:
84+
- kvs
85+
sbom: false
86+
flags:
87+
- "--provenance=false"
88+
tags:
89+
- "{{ .Tag }}-alpine"
90+
- "v{{ .Major }}.{{ .Minor }}-alpine"
91+
- "v{{ .Major }}-alpine"
92+
- "latest-alpine"
93+
labels:
94+
org.opencontainers.image.created: "{{ .Date }}"
95+
org.opencontainers.image.source: "https://github.com/skyoo2003/kvs"
96+
org.opencontainers.image.title: "{{ .ProjectName }}"
97+
org.opencontainers.image.revision: "{{ .FullCommit }}"
98+
org.opencontainers.image.version: "{{ .Version }}"
9599

96100
release:
97101
github:
98102
owner: skyoo2003
99103
name: kvs
100104
name_template: "v{{ .Version }}"
101105
disable: false
106+
mode: replace

Dockerfile.goreleaser

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
FROM alpine:3.23
1+
FROM --platform=$BUILDPLATFORM alpine:3.23
22

3+
RUN adduser --system --home /kvs appuser
34
VOLUME /kvs
45
WORKDIR /kvs
5-
COPY kvs /usr/bin/kvs
6+
ARG TARGETOS
7+
ARG TARGETARCH
8+
COPY ${TARGETOS}/${TARGETARCH}/kvs /usr/bin/kvs
69

710
EXPOSE 3456
811

12+
USER appuser
913
ENTRYPOINT ["kvs"]

Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.PHONY: all setup clean build test lint
1+
.PHONY: all setup clean build test lint lint-fix vet coverage race
22

3-
all: lint test build
3+
all: vet lint test build
44

55
setup:
66
@pre-commit install
@@ -16,3 +16,17 @@ test:
1616

1717
lint:
1818
@golangci-lint run ./...
19+
20+
lint-fix:
21+
@golangci-lint run --fix ./...
22+
23+
vet:
24+
@go vet ./...
25+
26+
coverage:
27+
@go test ./... -coverprofile=coverage.out -covermode=atomic
28+
@go tool cover -html=coverage.out -o coverage.html
29+
@echo "Coverage report: coverage.html"
30+
31+
race:
32+
@go test -race ./...

changes/header.tpl.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +0,0 @@
1-
# Changelog
2-
All notable changes to this project will be documented in this file.
3-
4-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5-
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
6-
and is generated by [Changie](https://github.com/miniscruff/changie).

0 commit comments

Comments
 (0)