Skip to content
Merged
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
22 changes: 22 additions & 0 deletions .github/workflows/create-release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Create Release Branch

on:
push:
tags:
- "v[0-9]+.[0-9]+.0"

jobs:
create-release-branch:
name: Create release branch
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Create release branch
run: |
TAG="${GITHUB_REF#refs/tags/}"
# Extract major.minor from tag (e.g. v0.1.0 -> release-v0.1)
BRANCH="release-${TAG%.*}"
git switch -c "${BRANCH}"
git push origin "${BRANCH}"
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.8
version: v2.10
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
## Tool Versions
ADDLICENSE_VERSION ?= v1.1.1
GOIMPORTS_VERSION ?= v0.31.0
GOLANGCI_LINT_VERSION ?= v2.8
GOLANGCI_LINT_VERSION ?= v2.10
#ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
Expand Down
100 changes: 100 additions & 0 deletions hack/cherry-pick.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env bash

set -euo pipefail

usage() {
echo "Usage: $0 <PR-number> <release-branch>"
echo ""
echo "Cherry-pick a merged PR into a release branch and open a new PR."
echo ""
echo "Examples:"
echo " $0 123 release-v0.1"
echo " $0 456 release-v0.2"
echo ""
echo "Prerequisites:"
echo " - gh CLI installed and authenticated"
echo " - Clean working tree"
exit 1
}

if [[ $# -ne 2 ]]; then
usage
fi

PR_NUMBER="$1"
RELEASE_BRANCH="$2"

# Verify gh CLI is available
if ! command -v gh &>/dev/null; then
echo "Error: gh CLI is not installed. See https://cli.github.com/"
exit 1
fi

# Verify clean working tree
if [[ -n "$(git status --porcelain)" ]]; then
echo "Error: working tree is not clean. Please commit or stash your changes."
exit 1
fi

# Verify the release branch exists on remote
if ! git ls-remote --exit-code --heads origin "${RELEASE_BRANCH}" &>/dev/null; then
echo "Error: branch '${RELEASE_BRANCH}' does not exist on remote."
exit 1
fi

# Get the merge commit SHA for the PR
MERGE_COMMIT=$(gh pr view "${PR_NUMBER}" --json mergeCommit --jq '.mergeCommit.oid')
if [[ -z "${MERGE_COMMIT}" || "${MERGE_COMMIT}" == "null" ]]; then
echo "Error: PR #${PR_NUMBER} has no merge commit. Is it merged?"
exit 1
fi

PR_TITLE=$(gh pr view "${PR_NUMBER}" --json title --jq '.title')
CHERRY_PICK_BRANCH="cherry-pick-${PR_NUMBER}-into-${RELEASE_BRANCH}"

echo "Cherry-picking PR #${PR_NUMBER} (\"${PR_TITLE}\") into ${RELEASE_BRANCH}"
echo " Merge commit: ${MERGE_COMMIT}"
echo " Branch: ${CHERRY_PICK_BRANCH}"
echo ""

# Fetch latest remote state
git fetch origin "${RELEASE_BRANCH}"

# Create cherry-pick branch from the release branch
if git show-ref --verify --quiet "refs/heads/${CHERRY_PICK_BRANCH}"; then
echo "Error: local branch '${CHERRY_PICK_BRANCH}' already exists."
echo "If it is left over from a previous attempt, delete it with:"
echo " git branch -D ${CHERRY_PICK_BRANCH}"
exit 1
fi
git switch -c "${CHERRY_PICK_BRANCH}" "origin/${RELEASE_BRANCH}"

# Fetch the merge commit (it may not exist locally yet)
git fetch origin "${MERGE_COMMIT}"

# Use -m1 only for true merge commits (more than one parent)
PARENT_COUNT=$(git rev-list --parents -n1 "${MERGE_COMMIT}" | wc -w)
# rev-list output includes the commit itself, so >2 words means multiple parents
CHERRY_PICK_ARGS=("-x")
if [[ "${PARENT_COUNT}" -gt 2 ]]; then
CHERRY_PICK_ARGS+=("-m1")
fi

if ! git cherry-pick "${CHERRY_PICK_ARGS[@]}" "${MERGE_COMMIT}"; then
echo ""
echo "Cherry-pick has conflicts. Please resolve them, then run:"
echo " git cherry-pick --continue"
echo " git push origin ${CHERRY_PICK_BRANCH}"
echo " gh pr create --base ${RELEASE_BRANCH} --title \"🍒 [${RELEASE_BRANCH}] ${PR_TITLE}\" --body \"Cherry-pick of #${PR_NUMBER} into ${RELEASE_BRANCH}.\""
exit 1
fi

# Push and create PR
git push origin "${CHERRY_PICK_BRANCH}"
gh pr create \
--base "${RELEASE_BRANCH}" \
--title "🍒 [${RELEASE_BRANCH}] ${PR_TITLE}" \
--body "Cherry-pick of #${PR_NUMBER} into \`${RELEASE_BRANCH}\`."

echo ""
echo "Done."
2 changes: 1 addition & 1 deletion pkg/cloudprovider/metal/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var _ = BeforeSuite(func() {
// Note that you must have the required binaries setup under the bin directory to perform
// the tests directly. When we run make test it will be setup and used automatically.
BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s",
fmt.Sprintf("1.34.0-%s-%s", runtime.GOOS, runtime.GOARCH)),
fmt.Sprintf("1.35.0-%s-%s", runtime.GOOS, runtime.GOARCH)),
}

var err error
Expand Down
Loading