diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml new file mode 100644 index 000000000..2293993fe --- /dev/null +++ b/.github/workflows/pre-release.yml @@ -0,0 +1,47 @@ +name: Pre-release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + discussions: write + +jobs: + build-and-create-prerelease: + runs-on: ubuntu-latest + steps: + - name: Checkout (full history) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + id: go + - name: Extract versions from go.mod + id: versions + run: | + # Extract Go version from go.mod + GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}') + echo "go-version=${GO_VERSION}" >> $GITHUB_OUTPUT + + # Extract k8s.io/client-go version from go.mod + CLIENT_GO_VERSION=$(go list -m -f '{{.Version}}' k8s.io/client-go) + echo "client-go-version=${CLIENT_GO_VERSION}" >> $GITHUB_OUTPUT + + echo "📦 Go version: ${GO_VERSION}" + echo "📦 k8s.io/client-go version: ${CLIENT_GO_VERSION}" + - name: Make pre-release + uses: goreleaser/goreleaser-action@v6 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GO_VERSION: ${{ steps.versions.outputs.go-version }} + K8S_CLIENT_VERSION: ${{ steps.versions.outputs.client-go-version }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 000000000..fa29872fc --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,73 @@ +version: 2 + +archives: + - formats: [tar.gz] + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + +changelog: + use: github + sort: asc + groups: + - title: "Features" + regexp: "(?i)(feat|feature|\\[feature\\]|\\[feat\\]|\\bFEATURE\\b)" + order: 1 + - title: "Bug Fixes" + regexp: "(?i)(fix|bugfix|\\[bugfix\\]|\\[BUGFIX\\]|\\bBUGFIX\\b)" + order: 2 + - title: "Documentation" + regexp: "(?i)(docs?|documentation|\\[docs?\\])" + order: 3 + - title: "Dependencies" + regexp: "(?i)(build\\(deps\\)|bump|dependencies)" + order: 4 + - title: "Maintenance" + regexp: "(?i)(chore|refactor|\\[chore\\])" + order: 5 + - title: "Other Changes" + regexp: ".*" + order: 99 + + filters: + exclude: + - '^docs:' + - '^test:' + - 'merge conflict' + - 'Merge branch' + - 'Merge pull request' + +release: + github: + owner: kubernetes + name: kube-state-metrics + + prerelease: "true" + + header: | + ## {{ .Tag }} / {{ .Now.Format "2006-01-02" }} + + {{- if index .Env "GO_VERSION" }} + ## Note + - This release builds with Go `{{ index .Env "GO_VERSION" }}` + {{- end }} + + {{- if index .Env "K8S_CLIENT_VERSION" }} + - This release builds with `k8s.io/client-go`: `{{ index .Env "K8S_CLIENT_VERSION" }}` + {{- end }} + + footer: | + **Full Changelog**: {{ .GitURL }}/compare/{{ .PreviousTag }}...{{ .Tag }} + + mode: replace + + # If set, will create a release discussion in the category specified. + # Warning: do not use categories in the 'Announcement' format. + # Check https://github.com/goreleaser/goreleaser/issues/2304 for more info. + # Default: ''. + discussion_category_name: Releases