Skip to content

Commit 0c0b972

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

File tree

2 files changed

+123
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)