Skip to content

Commit 2e0ef11

Browse files
committed
chore(ci): introduce github actions workflow to automate release tasks
Adds a workflow triggered by tag pushes to automate release tasks, including documentation generation via `docgen.sh`, Helm chart version bump and creation of a release pull request via `release.sh` that creates a "release-v*" branch. Integrates these scripts into Makefile targets and defines the workflow in `.github/workflows/release.yml`. Signed-off-by: Tsubasa Watanabe <[email protected]>
1 parent 3ed490d commit 2e0ef11

File tree

5 files changed

+84
-2
lines changed

5 files changed

+84
-2
lines changed

.github/workflows/release.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- 'v[0-9]+.[0-9]+.[0-9]+'
6+
- 'v*-test'
7+
jobs:
8+
release:
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
if: github.repository == 'kubernetes-sigs/karpenter-provider-cluster-api'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v5
16+
with:
17+
fetch-depth: 0
18+
- run: make docgen
19+
- run: make release
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
GITHUB_REPO: ${{ github.repository }}
23+
- name: create pull request
24+
uses: actions/github-script@v8
25+
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
script: |
28+
await github.rest.pulls.create({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
title: `chore(release): release ${context.ref_name} (automated)`,
32+
head: `release-${context.ref_name}`,
33+
base: 'main',
34+
body: `Release Changes for \`${context.ref_name}\`
35+
36+
### Changes included:
37+
- Created release branch \`release-${context.ref_name}\`
38+
- Automatically generated documentation
39+
- Bumped Helm chart version to \`${context.ref_name}\`
40+
41+
This PR was generated automatically by karpenter-provider-cluster-api/.github/workflows/release.yml
42+
`
43+
draft: false
44+
});

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,11 @@ vendor: ## update modules and populate local vendor directory
7070
go mod tidy
7171
go mod vendor
7272
go mod verify
73+
74+
.PHONY: docgen
75+
docgen: ## Generate documentation files
76+
./hack/docgen.sh
77+
78+
.PHONY: release
79+
release: ## Create a release branch, update chart version, and push changes
80+
./hack/release.sh

RELEASE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The Kubernetes Template Project is released on an as-needed basis. The process i
44

55
1. An issue is proposing a new release with a changelog since the last release
66
2. All [OWNERS](OWNERS) must LGTM this release
7-
3. Bump the `version` and `appVersion` of the Helm chart in `charts/karpenter/Chart.yaml`
8-
4. An OWNER runs `git tag -s $VERSION` and inserts the changelog and pushes the tag with `git push $VERSION`
7+
3. An OWNER runs `git tag -s $VERSION` and inserts the changelog and pushes the tag with `git push $VERSION`
8+
4. All [OWNERS](OWNERS) must approve the release PR automatically created by GitHub Actions
99
5. The release issue is closed
1010
6. An announcement email is sent to `[email protected]` with the subject `[ANNOUNCE] kubernetes-template-project $VERSION is released`

hack/docgen.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -eu -o pipefail
3+
4+
go run hack/docs/settings_gen/main.go docs/docs/settings.md

hack/release.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
set -eu -o pipefail
3+
4+
git_tag="$(git describe --exact-match --tags || echo "none")"
5+
if [[ "${git_tag}" != v* ]]; then
6+
echo "::notice::This commit is no tagged."
7+
exit 1
8+
fi
9+
10+
git config user.name "Release"
11+
git config user.email "[email protected]"
12+
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPO}"
13+
14+
branch_name="release-${git_tag}"
15+
git checkout -b "${branch_name}"
16+
17+
# Bump the version and appVersion of the Helm chart in charts/karpenter/Chart.yaml
18+
sed -i "s/^appVersion: .*/appVersion: \"${git_tag#v}\"/" charts/karpenter/Chart.yaml
19+
sed -i "s/^version: .*/version: ${git_tag#v}/" charts/karpenter/Chart.yaml
20+
21+
git add go.mod
22+
git add go.sum
23+
git add docs/docs
24+
git add charts/karpenter
25+
git commit -m "chore(release): release ${git_tag} (automated)"
26+
git push --set-upstream origin "${branch_name}"

0 commit comments

Comments
 (0)