Skip to content

Commit 1edc1c7

Browse files
committed
ci(template): Change operator version behaviour
Previously, we only used 0.0.0-prXXX for the image tag if the PR targeted the main branch. This could lead to surprising results, because some PRs might be raised against a different feature branch (potentially part of a different PR). In these cases, the current version (most likely 0.0.0-dev) would be used and the -prXXX was appended to it, resulting in a surprising version tag 0.0.0-dev-prXXX. To address this, we decided to only use the current version for PRs raised against release branches where this version scheme makes sense (that behaviour was also our intend when we initially wrote that script). For ANY other branch, we now always use 0.0.0-prXXX. We could further improve the logic by checking if the current version differs from 0.0.0-dev and then use the version as is with a -prXXX suffix. If the version is 0.0.0-dev, we use the established 0.0.0-prXXX version.
1 parent ba82093 commit 1edc1c7

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

template/.github/workflows/build.yaml.j2

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,18 @@ jobs:
151151

152152
CURRENT_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "stackable-{[ operator.name }]") | .version')
153153

154+
# Include a PR suffix if this workflow is triggered by a PR
154155
if [ "$GITHUB_EVENT_NAME" == 'pull_request' ]; then
155-
# Include a PR suffix if this workflow is triggered by a PR
156-
if [ "$PR_BASE_REF" == 'main' ]; then
157-
NEW_VERSION="0.0.0-pr$PR_NUMBER"
158-
else
156+
# If the PR is raised against a release branch, use the current operator version and
157+
# append a suffix to it. If the PR is raised against ANY other base branch, use the
158+
# established 0.0.0-prXXX tag.
159+
if [[ "$PR_BASE_REF" =~ ^release-[0-9]{2}\.[0-9]{1,2}$ ]]; then
159160
NEW_VERSION="$CURRENT_VERSION-pr$PR_NUMBER"
161+
else
162+
# NOTE (@Techassi): One could argue that we should warn the developer when the current
163+
# version is not 0.0.0-dev (and the PR potentially doesn't target main) that we will
164+
# still rewrite the version to 0.0.0-prXXX.
165+
NEW_VERSION="0.0.0-pr$PR_NUMBER"
160166
fi
161167
else
162168
# Just use the current version if this workflow is run on push, schedule, etc...

0 commit comments

Comments
 (0)