chore(release): Add prepare release script - #185
Conversation
E2E Test ResultsCommit: 6a8fe63 |
❌ 2 Tests Failed:
View the full list of 2 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
janisz
left a comment
There was a problem hiding this comment.
Good structure — follows the same clean patterns as start-y-stream-release.sh. The regex escaping is consistently correct (all dots properly escaped), and the substitution ordering (X.Y.Z before X.Y) correctly avoids substring collisions. The WARNING-replace-before-create-WARNING snapshot placeholder is a nice safety mechanism. Two minor suggestions, no blocking issues.
| discover_next_version() { | ||
| local latest_tag | ||
| latest_tag=$(git -C "${REPO_DIR}" tag -l "${VERSION}.*" --sort=-version:refname | head -1) |
There was a problem hiding this comment.
Suggestion: The glob "${VERSION}.*" also matches pre-release tags like 0.2.0-rc1. If one is picked, ${latest_tag##*.} extracts 0-rc1 and the arithmetic on line 114 crashes with rc1: unbound variable (thanks to set -u). The crash is safe — it prevents wrong versions — but the error message is confusing.
Filtering to bare X.Y.Z tags would make this more robust and give a clearer failure mode:
latest_tag=$(git -C "${REPO_DIR}" tag -l "${VERSION}.*" --sort=-version:refname | grep -E "^${VERSION}\.[0-9]+$" | head -1)|
|
||
| log "Checking out branch ${branch}..." | ||
| git -C "${REPO_DIR}" checkout "${branch}" | ||
| git -C "${REPO_DIR}" pull origin "${branch}" |
There was a problem hiding this comment.
Suggestion: git pull without --ff-only could silently create a merge commit if the local branch diverged. Using --ff-only would fail fast instead, which is safer for an automation script:
git -C "${REPO_DIR}" pull --ff-only origin "${branch}"| yq -i '.metadata.generateName |= (sub("X-Y-Z", env(RELEASE_VERSION_DASHED)) | sub("X-Y", env(VERSION_DASHED)) | sub("RELEASE_ENV", env(RELEASE_ENV)))' "${target}" | ||
| yq -i '.metadata.labels."release.appstudio.openshift.io/author" = env(RELEASE_AUTHOR)' "${target}" | ||
| yq -i '.spec.releasePlan |= (sub("RELEASE_ENV", env(RELEASE_ENV)) | sub("X-Y", env(VERSION_DASHED)))' "${target}" | ||
| yq -i '(.spec.data.mapping.defaults.tags[] | select(test("X\\.Y\\.Z"))) |= sub("X\\.Y\\.Z", env(RELEASE_VERSION))' "${target}" |
There was a problem hiding this comment.
Clean work — dots are consistently escaped in the regex patterns here, and the substitution order (X.Y.Z before X.Y, X-Y-Z before X-Y) correctly prevents substring collisions. Good improvement over the parent PR's inconsistent escaping.
Description
Adds a
scripts/prepare-release.shscript that automates patch release preparation for existing Y-stream release branches. The script discovers the next Z version from git tags (e.g., if0.2.1exists, next is0.2.2; if no tags exist, starts atX.Y.0), creates arelease-X-Y-Z-preparebranch, bumpsversionandappVersionincharts/stackrox-mcp/Chart.yaml, and generates Konflux Release resource YAMLs for both stage and production environments.Release resource files are generated from a single template (
scripts/templates/release-resource.yaml) usingyqpath-targetedsub()substitutions withX.Y/X-Y/X.Y.Z/X-Y-Zplaceholders. Output files are placed inreleases/X.Y.Z/at the repo root. The script does not commit or push — it prepares all changes for review.Validation
X.Y.0Chart.yamlhas correctversionandappVersionafter runningsnapshotfield isWARNING-replace-before-create-WARNINGrelease.appstudio.openshift.io/authoris set to current$USERgenerateNamefollows theagentic-cluster-security-suite-X-Y--X-Y-Z--{stage|prod}-patternAI-assisted development prompts
This PR was developed with AI assistance. Below are the prompts used: