Skip to content

Commit ce4dbd4

Browse files
authored
Create release branches for minor versions (#159)
1 parent 1378247 commit ce4dbd4

File tree

5 files changed

+125
-3
lines changed

5 files changed

+125
-3
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Create Release Branch
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.0"
7+
8+
jobs:
9+
create-release-branch:
10+
name: Create release branch
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v6
16+
- name: Create release branch
17+
run: |
18+
TAG="${GITHUB_REF#refs/tags/}"
19+
# Extract major.minor from tag (e.g. v0.1.0 -> release-v0.1)
20+
BRANCH="release-${TAG%.*}"
21+
git switch -c "${BRANCH}"
22+
git push origin "${BRANCH}"

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ jobs:
1717
- name: golangci-lint
1818
uses: golangci/golangci-lint-action@v9
1919
with:
20-
version: v2.8
20+
version: v2.10

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
111111
## Tool Versions
112112
ADDLICENSE_VERSION ?= v1.1.1
113113
GOIMPORTS_VERSION ?= v0.31.0
114-
GOLANGCI_LINT_VERSION ?= v2.8
114+
GOLANGCI_LINT_VERSION ?= v2.10
115115
#ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
116116
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
117117
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)

hack/cherry-pick.sh

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
usage() {
6+
echo "Usage: $0 <PR-number> <release-branch>"
7+
echo ""
8+
echo "Cherry-pick a merged PR into a release branch and open a new PR."
9+
echo ""
10+
echo "Examples:"
11+
echo " $0 123 release-v0.1"
12+
echo " $0 456 release-v0.2"
13+
echo ""
14+
echo "Prerequisites:"
15+
echo " - gh CLI installed and authenticated"
16+
echo " - Clean working tree"
17+
exit 1
18+
}
19+
20+
if [[ $# -ne 2 ]]; then
21+
usage
22+
fi
23+
24+
PR_NUMBER="$1"
25+
RELEASE_BRANCH="$2"
26+
27+
# Verify gh CLI is available
28+
if ! command -v gh &>/dev/null; then
29+
echo "Error: gh CLI is not installed. See https://cli.github.com/"
30+
exit 1
31+
fi
32+
33+
# Verify clean working tree
34+
if [[ -n "$(git status --porcelain)" ]]; then
35+
echo "Error: working tree is not clean. Please commit or stash your changes."
36+
exit 1
37+
fi
38+
39+
# Verify the release branch exists on remote
40+
if ! git ls-remote --exit-code --heads origin "${RELEASE_BRANCH}" &>/dev/null; then
41+
echo "Error: branch '${RELEASE_BRANCH}' does not exist on remote."
42+
exit 1
43+
fi
44+
45+
# Get the merge commit SHA for the PR
46+
MERGE_COMMIT=$(gh pr view "${PR_NUMBER}" --json mergeCommit --jq '.mergeCommit.oid')
47+
if [[ -z "${MERGE_COMMIT}" || "${MERGE_COMMIT}" == "null" ]]; then
48+
echo "Error: PR #${PR_NUMBER} has no merge commit. Is it merged?"
49+
exit 1
50+
fi
51+
52+
PR_TITLE=$(gh pr view "${PR_NUMBER}" --json title --jq '.title')
53+
CHERRY_PICK_BRANCH="cherry-pick-${PR_NUMBER}-into-${RELEASE_BRANCH}"
54+
55+
echo "Cherry-picking PR #${PR_NUMBER} (\"${PR_TITLE}\") into ${RELEASE_BRANCH}"
56+
echo " Merge commit: ${MERGE_COMMIT}"
57+
echo " Branch: ${CHERRY_PICK_BRANCH}"
58+
echo ""
59+
60+
# Fetch latest remote state
61+
git fetch origin "${RELEASE_BRANCH}"
62+
63+
# Create cherry-pick branch from the release branch
64+
if git show-ref --verify --quiet "refs/heads/${CHERRY_PICK_BRANCH}"; then
65+
echo "Error: local branch '${CHERRY_PICK_BRANCH}' already exists."
66+
echo "If it is left over from a previous attempt, delete it with:"
67+
echo " git branch -D ${CHERRY_PICK_BRANCH}"
68+
exit 1
69+
fi
70+
git switch -c "${CHERRY_PICK_BRANCH}" "origin/${RELEASE_BRANCH}"
71+
72+
# Fetch the merge commit (it may not exist locally yet)
73+
git fetch origin "${MERGE_COMMIT}"
74+
75+
# Use -m1 only for true merge commits (more than one parent)
76+
PARENT_COUNT=$(git rev-list --parents -n1 "${MERGE_COMMIT}" | wc -w)
77+
# rev-list output includes the commit itself, so >2 words means multiple parents
78+
CHERRY_PICK_ARGS=("-x")
79+
if [[ "${PARENT_COUNT}" -gt 2 ]]; then
80+
CHERRY_PICK_ARGS+=("-m1")
81+
fi
82+
83+
if ! git cherry-pick "${CHERRY_PICK_ARGS[@]}" "${MERGE_COMMIT}"; then
84+
echo ""
85+
echo "Cherry-pick has conflicts. Please resolve them, then run:"
86+
echo " git cherry-pick --continue"
87+
echo " git push origin ${CHERRY_PICK_BRANCH}"
88+
echo " gh pr create --base ${RELEASE_BRANCH} --title \"🍒 [${RELEASE_BRANCH}] ${PR_TITLE}\" --body \"Cherry-pick of #${PR_NUMBER} into ${RELEASE_BRANCH}.\""
89+
exit 1
90+
fi
91+
92+
# Push and create PR
93+
git push origin "${CHERRY_PICK_BRANCH}"
94+
gh pr create \
95+
--base "${RELEASE_BRANCH}" \
96+
--title "🍒 [${RELEASE_BRANCH}] ${PR_TITLE}" \
97+
--body "Cherry-pick of #${PR_NUMBER} into \`${RELEASE_BRANCH}\`."
98+
99+
echo ""
100+
echo "Done."

pkg/cloudprovider/metal/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var _ = BeforeSuite(func() {
7272
// Note that you must have the required binaries setup under the bin directory to perform
7373
// the tests directly. When we run make test it will be setup and used automatically.
7474
BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s",
75-
fmt.Sprintf("1.34.0-%s-%s", runtime.GOOS, runtime.GOARCH)),
75+
fmt.Sprintf("1.35.0-%s-%s", runtime.GOOS, runtime.GOARCH)),
7676
}
7777

7878
var err error

0 commit comments

Comments
 (0)