Skip to content

Conversation

@Rishab87
Copy link
Contributor

What this PR does / why we need it:
In this PR I've added goreleaser config and a workflow which on tag push helps to generate release notes and create a pre release on github.

Test release: https://github.com/Rishab87/kube-state-metrics/releases/tag/v2.18.0

How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)
does not changes

Which issue(s) this PR fixes: (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged)
Related to #2756

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 30, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Rishab87
Once this PR has been reviewed and has the lgtm label, please assign mrueg for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 30, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Instrumentation Sep 30, 2025
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 30, 2025
Comment on lines 39 to 48
release:
github:
owner: Rishab87
name: kube-state-metrics
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be the release author (the one that the release will be attributed to)? If so, this should ideally infer the person who pushed the tag, as they will be responsible for reviewing the overall changeset.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no this is supposed to be the org, I'll change this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if this was still attributed to the person running the release, to maintain ownership records. So instead of a per-org. release like so:

Screenshot 2025-10-22 at 5 36 09 PM

I'd suggest a per-author release such as:

Screenshot 2025-10-22 at 5 37 33 PM

This is all assuming that the name shown in the image and attributed to the release is indeed derived from here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not possible to show the tag pusher name here, either we need a PAT of someone or we can show on the changelog itself released by: username.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Nevermind, then!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure what you mean by setting this to the "org"? I'd reckon it'd be a bot alias (since that doesn't require a PAT)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I've seen there is no direct way of changing bot alias in a release in goreleaser.

I'm not quite sure what you mean by setting this to the "org"?

In the snippet here I've changed the owner to k8s since it was supposed to be the org name here, it is not at all related to the author's name on release which we are discussing here.

owner: Rishab87
name: kube-state-metrics

prerelease: "true"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First a release candidate (e.g. v1.2.0-rc.0) should be cut. If after a period of 7 days no bugs or issues were reported after publishing the release candidate, a stable release (e.g. v1.2.0) can be cut.

Do we plan on running a prerelease: false workflow after 7 days?

Copy link
Contributor Author

@Rishab87 Rishab87 Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of creating a seperate post release workflow (for merging back to main and running kpromo first) after which we can mark the release as the main release manually (we need to do mark it as main manually because it needs to be done after the merging of the kpromo PR & the 7 day wait period).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather see that automated after a 7-day cron, mostly because it's easy to lose track of. Also, I believe the kpromo and "merging back into main" effort needs to be done for the pre-release too, ideally, all release steps need to be done for both pre-release and final release, so they may be sourced from a single script.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, I'll create a seperate PR with cron to check for pre release and mark it as main

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked the krpomo and merging back to main does not needs to be done for pre-release, it needs to be done before marking the release as main, this is what is mentioned in RELEASE.md, please do correct if I'm wrong, so do we still need a cron? Since we have to manually run post release after prow build is finished and then merge the PRs after 7 days.

Copy link
Member

@rexagod rexagod Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I guess it made sense to do a kpromo promotion for pre-release as well, so users can test out the image. But since we don't do that at the moment, and no one's asked us to do that anyway, let's keep it as you mentioned.

.goreleaser.yaml Outdated
Comment on lines 51 to 53
- This release builds with Go `v1.24.6`
- This release builds with `k8s.io/client-go`: `v0.33.4`
- This release is the last release that has endpoint metrics enabled by default. In the next release we will enable endpointslices metrics and disable endpoint metrics by default, since the endpoint resources are deprecated. You can still alter this behaviour in kube-state-metrics' config.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be dynamic?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you can use

  # Additional templated extra files to add to the release.
  # Those files will have their contents pass through the template engine,
  # and its results will be added to the release.
  #
  # This feature is only available in GoReleaser Pro.
  # Templates: allowed.
  templated_extra_files:
    - src: LICENSE.tpl
      dst: LICENSE.txt

to achieve this.

Copy link
Contributor Author

@Rishab87 Rishab87 Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the versions dyanmic by getting them from go.mod in wokflow and passing them in env

- 'Merge branch'
- 'Merge pull request'

release:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussions should allow user to report concerns between the prerelease-to-release period.

  # 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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if we can close the discussions once that period is over?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope we need to do that manually

footer: |
**Full Changelog**: {{ .GitURL }}/compare/{{ .PreviousTag }}...{{ .Tag }}

mode: replace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  # You can add extra pre-existing files to the release.
  # The filename on the release will be the last part of the path (base).
  # If another file with the same name exists, the last one found will be used.
  #
  # Templates: allowed.
  extra_files:
    - glob: ./path/to/file.txt
    - glob: ./glob/**/to/**/file/**/*
    - glob: ./glob/foo/to/bar/file/foobar/override_from_previous
    - glob: ./single_file.txt
      name_template: file.txt # note that this only works if glob matches 1 file only

I believe we'll need to use this to export the openvex and SBOMs? Or is that done without this already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they're built currently on creating a main release automatically, I don't think we should add them in pre-release here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure if we should skip them for pre-releases, I'd rather keep the pre-release and release workflow as coherent as possible, so the pre-release artifacts can be inspected as well. This pattern will allow us to have a nearly identical release copy to verify.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so for that I can create a seperate PR changing the existing workflow which exports openvex and sboms to run on both pre release and release?

.goreleaser.yaml Outdated
Comment on lines 3 to 4
builds:
- skip: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KSM isn't shipped as a library at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should build it then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should, as long as it invokes the in-house build target.

.goreleaser.yaml Outdated
builds:
- skip: true

archives: []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we do release tarballs:

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 }}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

due to skip build set to true , no artifacts are being uploaded as an asset

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now I've removed build skip and I'm able to build these tarballs

@Rishab87 Rishab87 force-pushed the automate-pre-release-with-goreleaser branch from 32f0445 to 0c0b972 Compare October 2, 2025 14:37
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 2, 2025
@Rishab87
Copy link
Contributor Author

Rishab87 commented Oct 2, 2025

@rexagod thanks for the review, I've addressed them, can you have a look again?
Test release after making changes: https://github.com/Rishab87/kube-state-metrics/releases/tag/v2.18.0

The full changelog compares to v2.16.0, I think that's because while releasing v2.17.0 & merging back to main, instead of release-2.17 the prep-v2.17.0 branch was merged back to main.

@Rishab87 Rishab87 force-pushed the automate-pre-release-with-goreleaser branch from 0c0b972 to af3802f Compare October 2, 2025 16:01
@Rishab87 Rishab87 requested a review from rexagod October 2, 2025 16:01
@rexagod
Copy link
Member

rexagod commented Oct 22, 2025

I'd push for keeping the release artifacts same as what we have currently:

Screenshot 2025-10-22 at 5 57 30 PM

and not generate per-arch artifacts since we do not have arch-specific build tags in KSM, it runs the same everywhere:

Screenshot 2025-10-22 at 5 58 44 PM

@mrueg
Copy link
Member

mrueg commented Oct 22, 2025

I'd push for keeping the release artifacts same as what we have currently:
Screenshot 2025-10-22 at 5 57 30 PM

and not generate per-arch artifacts since we do not have arch-specific build tags in KSM, it runs the same everywhere:
Screenshot 2025-10-22 at 5 58 44 PM

These artifacts are binaries, so we need to have them per arch unless I'm missing anything here.

@Rishab87
Copy link
Contributor Author

Rishab87 commented Oct 25, 2025

@rexagod @mrueg from the discussions above, I think this is fine as it is?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

4 participants