Skip to content

Commit ec6ea38

Browse files
mnenciagbartolinileonardocejlong49
authored
ci: introduce release branches (cloudnative-pg#346)
Introduce support for multiple minor releases, each with their own release branch. A release branch must always originate from the trunk (`main` branch), and corresponds to a new minor release. Development happens on the trunk, and bug fixes are cherry-picked in the actively supported release branches by the maintainers (this process needs to be documented in the future, and ideally part of the review from a maintainer). Sometimes, bug fixes might originate in the release branch as well. Release notes for patch/security versions are maintained in the release branch directly. The release scripts has been modified to work only from a release branch (it is no longer possible to release from the trunk). Integrate the contributors doc with instructions on the release process. Closes cloudnative-pg#321 Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com> Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> Signed-off-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com> Signed-off-by: John Long <john.long@enterprisedb.com> Co-authored-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> Co-authored-by: Leonardo Cecchi <leonardo.cecchi@enterprisedb.com> Co-authored-by: John Long <john.long@enterprisedb.com>
1 parent cd5ce97 commit ec6ea38

File tree

6 files changed

+123
-48
lines changed

6 files changed

+123
-48
lines changed

.github/workflows/release-pr.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ jobs:
1717
-
1818
name: Get tag
1919
run: |
20-
echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
20+
TAG=${GITHUB_REF##*/}
21+
DEST=$(echo ${TAG#v} | awk -F '[.]' '{print "release-"$1"."$2}')
22+
echo "TAG=${TAG}" >> $GITHUB_ENV
23+
echo "DEST=${DEST}" >> $GITHUB_ENV
2124
-
2225
name: Pull Request
2326
id: open-pr
2427
uses: repo-sync/pull-request@v2.6.2
2528
with:
26-
destination_branch: "main"
29+
destination_branch: ${{ env.DEST }}
2730
github_token: ${{ secrets.GITHUB_TOKEN }}
2831
pr_body: "Automated PR. Will trigger the ${{ env.TAG }} release when approved."
2932
pr_label: release

.github/workflows/release-tag.yml

+2-19
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
types:
77
- closed
88
branches:
9-
- main
9+
- release-*
1010

1111
jobs:
1212
tag:
@@ -15,29 +15,12 @@ jobs:
1515
-
1616
name: Checkout
1717
uses: actions/checkout@v3
18-
-
19-
name: Temporarily disable "include administrators" branch protection
20-
if: ${{ always() && github.ref == 'refs/heads/main' }}
21-
id: disable_include_admins
22-
uses: benjefferies/branch-protection-bot@1.0.7
23-
with:
24-
access_token: ${{ secrets.REPO_GHA_PAT }}
25-
branch: main
26-
enforce_admins: false
2718
-
2819
name: Create tag
29-
if: github.event.pull_request.merged == true && startsWith(${{ github.head_ref }}, "release/v")
20+
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/v')
3021
uses: christophebedard/tag-version-commit@v1.6.2
3122
with:
3223
token: ${{ secrets.REPO_GHA_PAT }}
3324
version_regex: '^Version tag to ([0-9]+\.[0-9]+\.[0-9]+)'
3425
version_tag_prefix: v
3526
dry_run: false
36-
-
37-
name: Enable "include administrators" branch protection
38-
uses: benjefferies/branch-protection-bot@1.0.7
39-
if: ${{ always() && github.ref == 'refs/heads/main' }}
40-
with:
41-
access_token: ${{ secrets.REPO_GHA_PAT }}
42-
branch: main
43-
enforce_admins: ${{ steps.disable_include_admins.outputs.initial_status }}

contribute/release_procedure.md

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Release procedure
2+
3+
This section describes how to release a new set of supported versions of
4+
CloudNativePG, and should be done by one of the maintainers of the project. It
5+
is a semi-automated process which requires human supervision.
6+
7+
You can only release from a release branch, that is a branch in the
8+
Git repository called `release-X.Y`, i.e. `release-1.16`, which corresponds
9+
to a minor release.
10+
11+
The release procedure must be repeated for all the supported minor releases,
12+
usually 3:
13+
14+
- the current one (`release-X.Y`)
15+
- the previous one (`release-X.Y` -1)
16+
- the *"End of Life"* one (`release-X.Y` -2) - normally for an additional month
17+
after the first release of the current minor.
18+
19+
```diagram
20+
------+---------------------------------------------> main (trunk development)
21+
\ \
22+
\ \
23+
\ \ LATEST RELEASE
24+
\ \ ^
25+
\ \----------+---------------> release-X.Y |
26+
\ | SUPPORTED
27+
\ | RELEASES
28+
\ | = the two
29+
\ | last
30+
+-------------------+---------------> release-X.Y-1 | releases
31+
v
32+
```
33+
34+
## Release branches
35+
36+
A release branch must always originate from the *trunk* (`main` branch),
37+
and corresponds to a new minor release.
38+
39+
Development happens on the trunk (`main` branch), and bug fixes are
40+
cherry-picked in the actively supported release branches by the maintainers.
41+
Sometimes, bug fixes might originate in the release branch as well.
42+
Release notes for patch/security versions are maintained in the release branch
43+
directly.
44+
45+
## Planning the release
46+
47+
One or two weeks before the release, you should start planning the following
48+
activities:
49+
50+
- **Supported releases:** Make sure that you update the supported releases' page
51+
in `docs/src/supported_releases.md` and have been approved by the maintainers
52+
53+
- **Release notes:** Make sure release notes for the release have been updated
54+
in `docs/src/release_notes.md` and have been approved by the maintainers
55+
56+
- **Capabilities page:** in case of a new minor release, make sure that the
57+
operator capability levels page has been updated in
58+
`docs/src/operator_capability_levels.md` and approved by the maintainers
59+
60+
- **Documentation:** Make sure that you update the documentation in the
61+
[website project](https://github.com/cloudnative-pg/cloudnative-pg.github.io)
62+
for each of the supported releases via a PR.
63+
64+
<!-- TODO: we should create an issue template with a checklist for the release process -->
65+
66+
## Release steps
67+
68+
Once the code in the release branch is stable and ready to be released, you can
69+
proceed with the supervised process.
70+
71+
As a maintainer, you need to repeat this process for each of the supported
72+
releases of CloudNativePG:
73+
74+
1. Run `hack/release.sh X.Y.Z` (e.g. `hack/release.sh 1.16.0`)
75+
2. Quickly review the PR that is automatically generated by the script and
76+
approve it
77+
3. Merge the PR, making sure that the commit message title is:
78+
`Version tag to X.Y.Z`, without prefixes (e.g.: `Version tag to 1.16.0`)
79+
4. Wait until all [GitHub Actions](https://github.com/cloudnative-pg/cloudnative-pg/actions)
80+
complete successfully.
81+
5. Perform manual smoke tests to verify that installation instructions work on
82+
your workstation using `kind`
83+
84+
## Helm chart release:
85+
86+
After having created a new release of CloudNativePG you need to create a release of
87+
the `cloudnative-pg` and `cnpg-sandbox` charts, whose definitions can be found
88+
in the [cloudnative-pg/charts](https://github.com/cloudnative-pg/charts) repository.
89+
90+
The following is a summary of the steps to be taken in that direction. The
91+
[RELEASE.md](https://github.com/cloudnative-pg/charts/blob/a47596cb/RELEASE.md)
92+
document inside the relative repo contains an in-depth discussion of the
93+
process.
94+
95+
1. Copy the output of `kustomize build config/helm` to `charts/cloudnative-pg/templates/crds/crds.yaml`
96+
in the [cloudnative-pg/charts](https://github.com/cloudnative-pg/charts) repository.
97+
2. Diff the new release version with the previous one
98+
(e.g.: `vimdiff releases/cnpg-1.15.0.yaml releases/cnpg-1.15.1.yaml` using your IDE of choice)
99+
3. Port any diff to the templates in the helm chart accordingly
100+
4. Proceed with the release process described in the `RELEASE.md`
101+
file in the [cloudnative-pg/charts](https://github.com/cloudnative-pg/charts) repository.

contribute/to_be_classified.md

-24
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,3 @@ make licenses
1111
```
1212

1313
---
14-
15-
## Release procedure
16-
17-
### Initial verification
18-
19-
- Make sure release notes for the release have been updated
20-
in `docs/src/release_notes.md` and have been approved by
21-
the maintainers
22-
- Make sure that the operator capability levels page has been
23-
updated in `docs/src/operator_capability_levels.md` and approved
24-
by the maintainers
25-
26-
### Release steps
27-
28-
The following steps assume version 1.15.0 as the one to be released. Alter the
29-
instructions accordingly for your version.
30-
31-
1. Run `hack/release.sh 1.15.0`.
32-
2. Approve the PR that is automatically generated.
33-
3. Merge the PR.
34-
4. Wait until all [Github Actions](https://github.com/cloudnative-pg/cloudnative-pg/actions) finish.
35-
36-
---
37-

docs/src/supported_releases.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Git tags for versions are prepended with `v`.
6666
| Version | Currently Supported | Release Date | End of Life | Supported Kubernetes Versions | Tested, but not supported |
6767
|-----------------|----------------------|-------------------|--------------------------|-------------------------------|---------------------------|
6868
| main | No, development only | | | | |
69-
| 1.15.x | Yes | April 21, 2022 | October 15, 2022 | 1.21, 1.22, 1.23, 1.24 | 1.19, 1.20 |
69+
| 1.15.x | Yes | April 21, 2022 | October 15, 2022 | 1.21, 1.22, 1.23 | 1.19, 1.20, 1.24 |
7070
| 1.16.x | Yes | July 7, 2022 | ~ December 10, 2022 | 1.22, 1.23, 1.24 | 1.19, 1.20, 1.21 |
7171

7272
The list of supported Kubernetes versions in the above table depends on what

hack/release.sh

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/usr/bin/env bash
22
##
3+
## CloudNativePG release script
4+
##
5+
## This shell script automates the release process for a selected
6+
## version of CloudNativePG. It must be invoked from a release
7+
## branch. For details on the release procedure, please
8+
## refer to the contribute/release_procedure.md file from the
9+
## main folder.
10+
##
311
## Copyright The CloudNativePG Contributors
412
##
513
## Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,6 +35,7 @@ fi
2735

2836
release_version=${1#v}
2937

38+
# Verify we are working on a clean directory
3039
require_clean_work_tree () {
3140
git rev-parse --verify HEAD >/dev/null || exit 1
3241
git update-index -q --ignore-submodules --refresh
@@ -59,11 +68,12 @@ require_clean_work_tree () {
5968

6069
require_clean_work_tree "release"
6170

62-
if branch=$(git symbolic-ref --short -q HEAD) && [ "$branch" = 'main' ]
71+
# Verify that you are in a release branch
72+
if branch=$(git symbolic-ref --short -q HEAD) && [[ "$branch" == release-* ]]
6373
then
6474
echo "Releasing ${release_version}"
6575
else
66-
echo >&2 "Release is not possible because you are not on 'main' branch ($branch)"
76+
echo >&2 "Release is not possible because you are not on a 'release-*' branch ($branch)"
6777
exit 1
6878
fi
6979

@@ -73,6 +83,7 @@ KUSTOMIZE="${REPO_ROOT}/bin/kustomize"
7383
mkdir -p releases/
7484
release_manifest="releases/cnpg-${release_version}.yaml"
7585

86+
# Perform automated substitutions of the version string in the source code
7687
sed -i -e "/Version *= *.*/Is/\".*\"/\"${release_version}\"/" \
7788
-e "/DefaultOperatorImageName *= *.*/Is/\"\(.*\):.*\"/\"\1:${release_version}\"/" \
7889
pkg/versions/versions.go
@@ -90,6 +101,7 @@ cp -r config/* "${CONFIG_TMP_DIR}"
90101
"${KUSTOMIZE}" build "${CONFIG_TMP_DIR}/default" > "${release_manifest}"
91102
rm -fr "${CONFIG_TMP_DIR}"
92103

104+
# Create a new branch for the release that originates the PR
93105
git checkout -b "release/v${release_version}"
94106
git add \
95107
pkg/versions/versions.go \

0 commit comments

Comments
 (0)