Skip to content

Commit

Permalink
chore: allow releasing RCs from main branch
Browse files Browse the repository at this point in the history
Signed-off-by: Niccolò Fei <[email protected]>
  • Loading branch information
NiccoloFei authored and fcanovai committed Jun 25, 2024
1 parent e8bf44d commit f2d0925
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 29 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ jobs:
name: Get tag
run: |
TAG=${GITHUB_REF##*/}
DEST=$(echo ${TAG#v} | awk -F '[.]' '{print "release-"$1"."$2}')
if [[ "${TAG}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
DEST=$(echo ${TAG#v} | awk -F '[.]' '{print "release-"$1"."$2}')
else
DEST="main"
fi
echo "TAG=${TAG#v}" >> $GITHUB_ENV
echo "DEST=${DEST}" >> $GITHUB_ENV
-
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- closed
branches:
- release-*
- main
paths:
- 'pkg/versions/versions.go'

jobs:
tag:
Expand Down
24 changes: 15 additions & 9 deletions contribute/release_procedure.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ This section describes how to release a new set of supported versions of
CloudNativePG, which should be done by one of the project's maintainers.
It is a semi-automated process that requires human supervision.

You can only release from a release branch, that is a branch in the
Git repository called `release-X.Y`, e.g., `release-1.16`, which corresponds
to a minor release.
You can only release stable versions from a release branch, that is a branch
in the Git repository called `release-X.Y`, e.g., `release-1.16`, which
corresponds to a minor release.

The release procedure must be repeated for all the supported minor releases,
usually 3:
Expand Down Expand Up @@ -240,16 +240,22 @@ Open the `.github/ISSUE_TEMPLATES/bug.yml` file and update it accordingly.
## Release candidate

It's possible to create a release candidate (RC) for any of the
supported release branches. Unlike stable releases, a release candidate
might be released just for one release branch. As such, in this case the
release process doesn't necessarily have to be repeated for all the
supported release branches.
currently supported release branches, or also for a new minor release.
Unlike stable releases, a release candidate might be released just for one
version, and in this case the release process doesn't necessarily have to
be repeated for all the supported release branches.

**IMPORTANT:** RCs for currently supported release branches should be released
from the related release branch.
Instead, when releasing a RC for a new minor release (e.g a stable version
for that minor hasn't been released yet), that should be done from the
`main` branch.

To release a RC you can follow the [Release steps](#release-steps) until
point 5, taking care to use a valid semantic version when running the first
step (e.g., `hack/release.sh 1.16.0-rc1`).
See [Semantic Versioning 2.0.0 - Point 9](https://semver.org/#spec-item-9) to
See [Semantic Versioning 2.0.0 - item 9](https://semver.org/#spec-item-9) to
check for valid release candidate identifiers.

**IMPORTANT:** Release candidates can only be installed via the YAML manifest,
**NOTE:** Release candidates can only be installed via the YAML manifest,
other installation methods such as Helm Chart or OLM are currently not supported.
42 changes: 23 additions & 19 deletions hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,28 @@ require_clean_work_tree () {

require_clean_work_tree "release"

# Verify that you are in a release branch
if branch=$(git symbolic-ref --short -q HEAD) && [[ "$branch" == release-* ]]
then
# Verify that you are in a proper branch
# Releases can only be triggered from:
# - a release branch (for stable releases)
# - main (for release candidate only)
branch=$(git symbolic-ref --short -q HEAD)
case $branch in
release-*)
echo "Releasing ${release_version}"
else
echo >&2 "Release is not possible because you are not on a 'release-*' branch ($branch)"
;;
main)
if [[ "${release_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
then
echo >&2 "Cannot release a stable version from 'main'"
exit 1
fi
echo "Releasing ${release_version}"
;;
*)
echo >&2 "Release is not possible because you are not on 'main' or a 'release-*' branch ($branch)"
exit 1
fi

# Verify the maturity of the release
IS_STABLE=false
if [[ "${release_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
then
IS_STABLE=true
fi
;;
esac

make kustomize
KUSTOMIZE="${REPO_ROOT}/bin/kustomize"
Expand All @@ -95,12 +102,9 @@ sed -i -e "/Version *= *.*/Is/\".*\"/\"${release_version}\"/" \
-e "/DefaultOperatorImageName *= *.*/Is/\"\(.*\):.*\"/\"\1:${release_version}\"/" \
pkg/versions/versions.go

if [ "${IS_STABLE}" = true ]
then
sed -i -e "s@release-[0-9.]*/releases/cnpg-[0-9.]*.yaml@${branch}/releases/cnpg-${release_version}.yaml@g" \
-e "s@artifacts/release-[0-9.]*/@artifacts/${branch}/@g" \
docs/src/installation_upgrade.md
fi
sed -i -e "s@release-[0-9.]*/releases/cnpg-[0-9.]*.yaml@${branch}/releases/cnpg-${release_version}.yaml@g" \
-e "s@artifacts/release-[0-9.]*/@artifacts/${branch}/@g" \
docs/src/installation_upgrade.md

CONFIG_TMP_DIR=$(mktemp -d)
cp -r config/* "${CONFIG_TMP_DIR}"
Expand Down

0 comments on commit f2d0925

Please sign in to comment.