diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index c19557eac8..551cea3f34 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -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 - diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml index 884a34e11f..b9fcc094af 100644 --- a/.github/workflows/release-tag.yml +++ b/.github/workflows/release-tag.yml @@ -7,6 +7,9 @@ on: - closed branches: - release-* + - main + paths: + - 'pkg/versions/versions.go' jobs: tag: diff --git a/contribute/release_procedure.md b/contribute/release_procedure.md index 359b4d4ac8..77e0023a55 100644 --- a/contribute/release_procedure.md +++ b/contribute/release_procedure.md @@ -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: @@ -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. diff --git a/hack/release.sh b/hack/release.sh index a3a3ac95de..4b5802d83b 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -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" @@ -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}"