Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: automate release workflow #2325

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@

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

<!-- In case of the change being user-facing, an entry should be appended to the latest unreleased section in CHANGELOG.md.
The expected format is as follows:
- [ENHANCEMENT/CHANGE/BUGFIX/FEATURE]: <PR TITLE> by @PR_AUTHOR in https://github.com/kubernetes/kube-state-metrics/pull/<PR NUMBER> (avoid using #<PR NUMBER> for inter-VCS compatibility), for instance:
- [ENHANCEMENT]: Add support for Windows by @k8s-ci-robot in https://github.com/kubernetes/kube-state-metrics/pull/1234
- [ ] I have added a CHANGELOG entry for this change.
86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Release

on:
push:
tags:
- v*

permissions:
contents: write
pull-requests: write

env:
GO_VERSION: "^1.21"
GOLANGCI_LINT_VERSION: "v1.54.2"
E2E_SETUP_KIND: yes
E2E_SETUP_KUBECTL: yes

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Extract pushed release tag
id: extract_tag
run: echo "::set-output name=tag::${GITHUB_REF##*/}"
- name: Checkout into the corresponding release branch
uses: actions/checkout@v4
- name: Create VCS sandbox
run: |
git checkout -b release-${{ steps.extract_tag.outputs.tag }}
- name: Set up the Go@${{ env.GO_VERSION }} environment
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Get the pushed tag
id: get_tag
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Store the previous tag
id: get_previous_tag
run: echo ::set-output name=previous_tag::$(cat VERSION | cut -d. -f1,2)
- name: Update the VERSION manifest to the pushed tag
run: echo "${{ steps.get_tag.outputs.tag }}" | sed 's/^v//' > VERSION
- name: Update the compatibility matrix (README.md)
run: ./scripts/update-compatibility-matrix.sh
- name: Generate the release notes (CHANGELOG.md)
run: ./scripts/generate-release-notes.sh
- name: Install tools
run: make install-tools
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
sh -s -- -b $(go env GOPATH)/bin ${{ env.GOLANGCI_LINT_VERSION }}
make lint-fix
- name: Generate manifests
run: make examples
- name: Run rule tests
run: PROMTOOL_CLI=./promtool make install-promtool test-rules
- name: Run unit tests
run: make test-unit
- name: Run end-to-end tests
run: make e2e
- name: Update the remote and commit the changes
run: |
git config --local user.email "ksm-release-bot@mock-k8s.io"
git config --local user.name "KSM Release Bot"
git add .
git commit -m "chore: Cut ${{ steps.get_tag.outputs.tag }}"
git push origin HEAD:release-${{ steps.get_tag.outputs.tag }} --force-with-lease
- name: Benchmark tests
run: LATEST_RELEASE_BRANCH=release-${{ steps.get_previous_tag.outputs.previous_tag }} make test-benchmark-compare
- name: Validate docs
run: make doccheck
- name: Validate manifests
run: make validate-manifests
- name: Validate go modules
run: make validate-modules
- name: Create a pull request
run: |
gh pr create \
--title "chore: Cut ${{ steps.get_tag.outputs.tag }}" \
--body "This PR was automatically created by the release workflow, and should be targeted to the corresponding release branch." \
--base main \
--head release-${{ steps.get_tag.outputs.tag }}
--reviewer @sig-instrumentation-approvers \
--assignee @sig-instrumentation-leads
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
## v2.11.0 / 2024-03-04

### Note

This release builds with Golang `v1.21.7`.

* [ENHANCEMENT] Add OpenSSF Scorecard to README by @dalehenries in <https://github.com/kubernetes/kube-state-metrics/pull/2277>
* [ENHANCEMENT] Generate OpenVX data for every release by @shafeeqes in <https://github.com/kubernetes/kube-state-metrics/pull/2276>
* [ENHANCEMENT] Add restartPolicy to `kube_pod_init_container_info` metric by @changhyuni in <https://github.com/kubernetes/kube-state-metrics/pull/2240>
* [FEATURE] Add `kube_node_status_addresses` metric by @stonith in <https://github.com/kubernetes/kube-state-metrics/pull/2252>
* [FEATURE] Add namespace label to `endpointslice` metrics by @mrueg in <https://github.com/kubernetes/kube-state-metrics/pull/2266>
* [FEATURE] Add opt-in `kube_persistentvolume_csi_attributes` metric by @machadovilaca in <https://github.com/kubernetes/kube-state-metrics/pull/2133>
* [FEATURE] Add new metric `kube_pod_scheduler` metric by @adinhodovic in <https://github.com/kubernetes/kube-state-metrics/pull/2222>
* [FEATURE] Support filtering annotations allow-list by `*` by @xonvanetta in <https://github.com/kubernetes/kube-state-metrics/pull/2234>
* [ENHANCEMENT] Support scraping pod metrics that are still in scheduling status and have no assigned nodes by @mickeyzzc in <https://github.com/kubernetes/kube-state-metrics/pull/2217>
* [FEATURE] Add backend resource info for `kube_ingress_path` by @rohitphatak in <https://github.com/kubernetes/kube-state-metrics/pull/2109>

## v2.10.1 / 2023-10-09

### Note

* This release addresses a regression introduced in [#2105](https://github.com/kubernetes/kube-state-metrics/pull/2105).

* [BUGFIX] Remove FieldSelector from non-namespaced resources by @mrueg and @dgrisonnet in [#2190](https://github.com/kubernetes/kube-state-metrics/pull/2190)
* [ENHANCEMENT] Bump Go to v1.20.8

## v2.10.0 / 2023-08-31

### Note
Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ REGISTRY ?= gcr.io/k8s-staging-kube-state-metrics
TAG_PREFIX = v
VERSION = $(shell cat VERSION)
TAG ?= $(TAG_PREFIX)$(VERSION)
LATEST_RELEASE_BRANCH := release-$(shell grep -ohE "[0-9]+.[0-9]+" VERSION)
LATEST_RELEASE_BRANCH ?= release-$(shell grep -ohE "[0-9]+.[0-9]+" VERSION)
BRANCH = $(strip $(shell git rev-parse --abbrev-ref HEAD))
DOCKER_CLI ?= docker
PROMTOOL_CLI ?= promtool
Expand All @@ -21,6 +21,7 @@ IMAGE = $(REGISTRY)/kube-state-metrics
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
USER ?= $(shell id -u -n)
HOST ?= $(shell hostname)
MARKDOWNFMT = $(shell which markdownfmt)
MARKDOWNLINT_CLI2_VERSION = 0.9.2


Expand All @@ -43,10 +44,10 @@ licensecheck:
exit 1; \
fi

lint: shellcheck licensecheck lint-markdown-format
lint: shellcheck licensecheck lint-markdownfmt lint-markdown-format
golangci-lint run

lint-fix: fix-markdown-format
lint-fix: lint-markdownfmt-fix fix-markdown-format
golangci-lint run --fix -v


Expand Down Expand Up @@ -84,6 +85,12 @@ shellcheck:
lint-markdown-format:
${DOCKER_CLI} run -v "${PWD}:/workdir" davidanson/markdownlint-cli2:v${MARKDOWNLINT_CLI2_VERSION} --config .markdownlint-cli2.jsonc

lint-markdownfmt:
${MARKDOWNFMT} -d -gofmt README.md

lint-markdownfmt-fix:
${MARKDOWNFMT} -w -gofmt README.md

fix-markdown-format:
${DOCKER_CLI} run -v "${PWD}:/workdir" davidanson/markdownlint-cli2:v${MARKDOWNLINT_CLI2_VERSION} --fix --config .markdownlint-cli2.jsonc

Expand Down
Loading