Skip to content

Commit 17e4b1a

Browse files
authored
Merge pull request #28 from embik/automate-provider-releases
🌱 Define release process and provide script to create release commit
2 parents 31313e6 + 458c545 commit 17e4b1a

File tree

4 files changed

+98
-77
lines changed

4 files changed

+98
-77
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ APIDIFF_OLD_COMMIT ?= $(shell git rev-parse origin/main)
177177
verify-apidiff: $(GO_APIDIFF) ## Check for API differences
178178
$(GO_APIDIFF) $(APIDIFF_OLD_COMMIT) --print-compatible
179179

180+
## --------------------------------------
181+
## Release Tooling
182+
## --------------------------------------
183+
184+
185+
.PHONY: provider-release
186+
provider-release: ## Create a commit bumping the provider modules to the latest release tag and tag providers.
187+
@./hack/release-providers.sh
188+
180189
## --------------------------------------
181190
## Helpers
182191
## --------------------------------------

docs/development/release-process.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Release Process
2+
3+
This repository includes serveral Go modules: The "main" Go module `sigs.k8s.io/multicluster-runtime` and several provider modules.
4+
5+
The release process is partially automated. The following steps need to be taken:
6+
7+
1. Create a new branch, e.g. `prepare-0.24.0-alpha.7` from `main` (or the respective release branch).
8+
2. Run `./hack/release-commit.sh <version>` (e.g. `./hack/release-commit.sh v0.24.0-alpha.7`).
9+
3. Push the resulting branch and open a PR to get it merged into `main` (or the respective release branch).
10+
4. Once merged, follow the instructions in the output of `./hack/release-commit.sh` and push the release tags.
11+
12+
This release process makes sure that _all_ tags for a release are on the same commit (the commit generated by the script).
13+
14+
## `release-commit.sh`
15+
16+
Behaviour of this script can be adjusted with the following environment variables:
17+
18+
- `GIT_TAG_OPTIONS`: Optional flags to be passed to `git tag`. Example: `GIT_TAG_OPTIONS=-s` to sign git tags with your GPG key.
19+
- `GIT_COMMIT_OPTIONS`: Optional flags to be passed to `git commit`. Example: `GIT_COMMIT_OPTIONS=-s -S` to sign-off on your commits and sign them with your GPG key.
20+
- `GIT_COMMIT_PUSH` and `GIT_COMMIT_REMOTE`: To push the release commit automatically. Need to be both set. Example: `GIT_COMMIT_PUSH=1 GIT_COMMIT_REMOTE=fork`.
21+
22+
## Versioning
23+
24+
`sigs.k8s.io/multicluster-runtime` follows the `sigs.k8s.io/controller-runtime` version for ease of use (e.g. the version of multicluster-runtime that depends on controller-runtime `v0.20.4` must also be `v0.20.4`). Make sure that [go.mod](../../go.mod) contains the right dependency before tagging a new release.

hack/release-commit.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#! /usr/bin/env bash
2+
# Copyright 2025 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o errexit
17+
18+
TAG=${1}
19+
GIT_TAG_OPTIONS=${GIT_TAG_OPTIONS:-}
20+
GIT_COMMIT_OPTIONS=${GIT_COMMIT_OPTIONS:-}
21+
GIT_COMMIT_PUSH=${GIT_COMMITS_PUSH:-}
22+
GIT_COMMIT_REMOTE=${GIT_COMMITS_REMOTE:-}
23+
24+
echo "Updating all modules ..."
25+
26+
find "providers" "examples" -name go.mod | while read -r GOMOD; do
27+
module=$(dirname "${GOMOD}")
28+
if [ "$(git tag -l "${module}/${TAG}")" ]; then
29+
echo "${module}/${LTAG} already exists. Do you really need to run this script?"
30+
exit 1
31+
fi
32+
33+
pushd "${module}"
34+
go get "sigs.k8s.io/multicluster-runtime@${TAG}"
35+
go mod tidy
36+
popd
37+
done
38+
39+
echo "Creating release commit ..."
40+
41+
git add ./providers/ ./examples/
42+
git commit -m "Prepare release for sigs.k8s.io/multicluster-runtime@${TAG}" ${GIT_COMMIT_OPTIONS}
43+
44+
if [ -n "$GIT_COMMIT_PUSH" ] && [ -n "$GIT_COMMIT_REMOTE" ]; then
45+
echo "Pushing release commit to ${GIT_COMMIT_REMOTE} ..."
46+
git push "${GIT_COMMIT_REMOTE}"
47+
fi
48+
49+
echo "Creating release tags ..."
50+
51+
# set up main tag
52+
git tag -am "${TAG}" "${TAG}" ${GIT_TAG_OPTIONS}
53+
echo "Created tag ${TAG}."
54+
55+
# create provider and example tags
56+
find "providers" "examples" -name go.mod | while read -r GOMOD; do
57+
module=$(dirname "${GOMOD}")
58+
git tag -am "${module}/${TAG}" "${module}/${TAG}" ${GIT_TAG_OPTIONS}
59+
echo "Created tag ${module}/${TAG}."
60+
done
61+
62+
echo ""
63+
echo "Tags have been successfully created on the release commit."
64+
echo "As a next step, open a PR for your branch in kubernetes-sigs/multicluster-runtime."
65+
echo "Once the PR has been merged, push all git tags created above.

hack/release.sh

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)