Skip to content

Commit af3802f

Browse files
committed
added goreleaser configs for notes generation and pre-release creation
1 parent e332175 commit af3802f

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

.github/workflows/pre-release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Pre-release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
discussions: write
11+
12+
jobs:
13+
build-and-create-prerelease:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout (full history)
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version-file: 'go.mod'
25+
id: go
26+
- name: Extract versions from go.mod
27+
id: versions
28+
run: |
29+
# Extract Go version from go.mod
30+
GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
31+
echo "go-version=${GO_VERSION}" >> $GITHUB_OUTPUT
32+
33+
# Extract k8s.io/client-go version from go.mod
34+
CLIENT_GO_VERSION=$(go list -m -f '{{.Version}}' k8s.io/client-go)
35+
echo "client-go-version=${CLIENT_GO_VERSION}" >> $GITHUB_OUTPUT
36+
37+
echo "📦 Go version: ${GO_VERSION}"
38+
echo "📦 k8s.io/client-go version: ${CLIENT_GO_VERSION}"
39+
- name: Make pre-release
40+
uses: goreleaser/goreleaser-action@v6
41+
with:
42+
version: latest
43+
args: release --clean
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
GO_VERSION: ${{ steps.versions.outputs.go-version }}
47+
K8S_CLIENT_VERSION: ${{ steps.versions.outputs.client-go-version }}

.goreleaser.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
version: 2
2+
3+
archives:
4+
- formats: [tar.gz]
5+
# this name template makes the OS and Arch compatible with the results of `uname`.
6+
name_template: >-
7+
{{ .ProjectName }}_
8+
{{- title .Os }}_
9+
{{- if eq .Arch "amd64" }}x86_64
10+
{{- else if eq .Arch "386" }}i386
11+
{{- else }}{{ .Arch }}{{ end }}
12+
{{- if .Arm }}v{{ .Arm }}{{ end }}
13+
14+
changelog:
15+
use: github
16+
sort: asc
17+
groups:
18+
- title: "Features"
19+
regexp: "(?i)(feat|feature|\\[feature\\]|\\[feat\\]|\\bFEATURE\\b)"
20+
order: 1
21+
- title: "Bug Fixes"
22+
regexp: "(?i)(fix|bugfix|\\[bugfix\\]|\\[BUGFIX\\]|\\bBUGFIX\\b)"
23+
order: 2
24+
- title: "Documentation"
25+
regexp: "(?i)(docs?|documentation|\\[docs?\\])"
26+
order: 3
27+
- title: "Dependencies"
28+
regexp: "(?i)(build\\(deps\\)|bump|dependencies)"
29+
order: 4
30+
- title: "Maintenance"
31+
regexp: "(?i)(chore|refactor|\\[chore\\])"
32+
order: 5
33+
- title: "Other Changes"
34+
regexp: ".*"
35+
order: 99
36+
37+
filters:
38+
exclude:
39+
- '^docs:'
40+
- '^test:'
41+
- 'merge conflict'
42+
- 'Merge branch'
43+
- 'Merge pull request'
44+
45+
release:
46+
github:
47+
owner: kubernetes
48+
name: kube-state-metrics
49+
50+
prerelease: "true"
51+
52+
header: |
53+
## {{ .Tag }} / {{ .Now.Format "2006-01-02" }}
54+
55+
{{- if index .Env "GO_VERSION" }}
56+
## Note
57+
- This release builds with Go `{{ index .Env "GO_VERSION" }}`
58+
{{- end }}
59+
60+
{{- if index .Env "K8S_CLIENT_VERSION" }}
61+
- This release builds with `k8s.io/client-go`: `{{ index .Env "K8S_CLIENT_VERSION" }}`
62+
{{- end }}
63+
64+
footer: |
65+
**Full Changelog**: {{ .GitURL }}/compare/{{ .PreviousTag }}...{{ .Tag }}
66+
67+
mode: replace
68+
69+
# If set, will create a release discussion in the category specified.
70+
# Warning: do not use categories in the 'Announcement' format.
71+
# Check https://github.com/goreleaser/goreleaser/issues/2304 for more info.
72+
# Default: ''.
73+
discussion_category_name: Releases

0 commit comments

Comments
 (0)