Skip to content

chore(release): Add start Y release script - #179

Open
mtodor wants to merge 1 commit into
mainfrom
mtodor/add-script-to-start-y-release
Open

chore(release): Add start Y release script#179
mtodor wants to merge 1 commit into
mainfrom
mtodor/add-script-to-start-y-release

Conversation

@mtodor

@mtodor mtodor commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds an automated script for starting Y-stream releases of the Agentic Cluster Security Suite. Previously, creating a new release stream required manual edits across two repositories (stackrox-mcp and konflux-release-data), which was error-prone and time-consuming.

The script scripts/start-y-stream-release.sh takes a version (e.g., 1.5) and the path to the konflux-release-data repo, then:

In stackrox-mcp:

  • Creates a release-x.y branch from origin/main
  • Updates Tekton pipeline files (labels, service account, CPE version) using yq
  • Commits and pushes the branch

In konflux-release-data:

  • Creates an agentic-suite-release-x-y branch from origin/main
  • Generates staging and production ReleasePlanAdmission YAMLs from templates
  • Creates release kustomization directory with proper suffix transformer and git revision
  • Updates parent kustomization.yaml resources list
  • Runs build-single.sh to validate kustomize build
  • Commits all changes (including auto-generated output) and pushes

YAML templates with X.Y / X-Y placeholders are stored in scripts/templates/. A --dry-run flag allows local-only execution without pushing.

Validation

  • Verify yq version check works (requires >= 4.52.1 for --yaml-compact-seq-indent)
  • Run with --dry-run to verify all file modifications without pushing
  • Verify Tekton YAML changes: only 4 fields change per file (application label, component label, serviceAccountName, CPE label)
  • Verify generated ReleasePlanAdmission YAMLs match expected format
  • Verify kustomization.yaml has correct revision and suffix
  • Verify build-single.sh kustomize build succeeds

AI-assisted development prompts

This PR was developed with AI assistance. Below are the prompts used:

Prompt: "I want to implement the following functionality. Create a script that will start Y stream release of Stackrox MCP. This script should take the following parameters: version in format x.y, konflux-data-repo directory. Pull the main branch and create a new branch release-x.y. In that branch modify Tekton files... Store templates in scripts/templates directory. Add dry-mode."
Response: Explored both repos (stackrox-mcp Tekton files and konflux-release-data ReleasePlanAdmission/kustomization structure), created a plan, and implemented the script with 3 YAML templates and the main orchestration script using sed-based substitution.

Prompt: "Don't use sed - can we use yq or maybe python. We could have python script dedicated for yaml updates."
Response: Switched the plan to use yq (v4, mikefarah) for all YAML modifications instead of sed, since all files are YAML.

Prompt: "Ensure scripts are nicely organized in functions with single domain of responsibility. Move git add and commit after build-single.sh. Use X.Y or X-Y placeholders similar to CPE."
Response: Reorganized the script into focused functions (validate_inputs, prepare_branch, update_tekton_pipelines, etc.), moved the konflux-release-data commit to after build-single.sh, and changed template placeholders from PLACEHOLDER to X.Y/X-Y.

Prompt: "For YAML in stackrox-mcp use --yaml-compact-seq-indent. Ensure yq version is 4.52.1 or higher."
Response: Added --yaml-compact-seq-indent flag to all yq calls for Tekton files and a yq version check (>= 4.52.1) in validate_inputs().

@mtodor
mtodor requested a review from janisz as a code owner July 28, 2026 16:39
@github-actions

Copy link
Copy Markdown

E2E Test Results

Commit: 6995c2d
Workflow Run: View Details
Artifacts: Download test results & logs

=== Evaluation Summary ===

  ✓ cve-detected-workloads (assertions: 3/3)
  ✓ cve-cluster-does-exist (assertions: 3/3)
  ✓ rhsa-not-supported (assertions: 2/2)
  ✓ cve-cluster-does-not-exist (assertions: 3/3)
  ✓ cve-cluster-list (assertions: 3/3)
  ✓ cve-nonexistent (assertions: 3/3)
  ✓ cve-clusters-general (assertions: 3/3)
  ✓ list-clusters (assertions: 3/3)
  ✓ cve-detected-clusters (assertions: 3/3)
  ✓ cve-multiple (assertions: 3/3)
  ✓ cve-log4shell (assertions: 3/3)

Tasks:      11/11 passed (100.00%)
Assertions: 32/32 passed (100.00%)
Tokens:     ~49662 (estimate - excludes system prompt & cache)
MCP schemas: ~12562 (included in token total)
Agent used tokens:
  Input:  11682 tokens
  Output: 19548 tokens
Judge used tokens:
  Input:  39388 tokens
  Output: 45490 tokens

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.37%. Comparing base (a1cba46) to head (6995c2d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #179   +/-   ##
=======================================
  Coverage   72.37%   72.37%           
=======================================
  Files          31       31           
  Lines        1383     1383           
=======================================
  Hits         1001     1001           
  Misses        336      336           
  Partials       46       46           
Flag Coverage Δ
integration 72.37% <ø> (ø)
unit 72.37% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added an automated release workflow for preparing and validating staged and production releases.
    • Added dry-run support to preview release changes without pushing updates.
    • Added templates for release plans and release-specific configuration, including versioned metadata, component mappings, and pipeline settings.
  • Validation
    • Release preparation now checks required inputs, tools, directories, and generated configuration before completion.

Walkthrough

Changes

The PR adds a Bash Y-stream release orchestrator that validates inputs, updates parent repository Tekton configuration, generates Konflux stage and production release resources, validates kustomize output, and supports dry-run execution without remote pushes.

Y-stream release workflow

Layer / File(s) Summary
Input validation and workflow orchestration
scripts/start-y-stream-release.sh
Parses version, repository, dry-run, and help arguments; validates tools, directories, version format, and yq; sequences both release workflows.
Parent repository release branch
scripts/start-y-stream-release.sh
Creates the release branch, updates selected Tekton pipeline labels and parameters, then commits and conditionally pushes .tekton/ changes.
Release resource generation
scripts/templates/*, scripts/start-y-stream-release.sh
Adds stage and production ReleasePlanAdmission templates, creates versioned admission files, and generates the release kustomization with version-specific substitutions.
Konflux validation and publication
scripts/start-y-stream-release.sh
Runs tenant configuration validation through build-single.sh, then commits and conditionally pushes the Konflux release-data branch.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ReleaseScript
  participant ParentRepository
  participant KonfluxReleaseData
  participant BuildSingle
  ReleaseScript->>ParentRepository: Create release branch and update Tekton configuration
  ReleaseScript->>ParentRepository: Commit and optionally push changes
  ReleaseScript->>KonfluxReleaseData: Generate release admissions and kustomization
  KonfluxReleaseData->>BuildSingle: Validate tenant configuration
  ReleaseScript->>KonfluxReleaseData: Commit and optionally push release-data branch
Loading

Suggested reviewers: janisz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: adding a Y-stream release start script.
Description check ✅ Passed The description is directly related to the script and templates added in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mtodor/add-script-to-start-y-release

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/start-y-stream-release.sh`:
- Around line 106-114: The release branch creation in
prepare_stackrox_mcp_branch and prepare_konflux_data_branch is not rerun-safe.
In scripts/start-y-stream-release.sh lines 106-114 and 155-163, replace each git
checkout -b invocation with checkout -B using the same branch name and
origin/main base, and add a brief comment noting that reruns reset and discard
local unpushed commits on the existing release branch.
- Line 203: Remove the `select(. == "*")` filter from the `.patches[0].patch`
update in the release-generation command, and apply `sub("release-X.Y", ...)`
directly to the patch text. Preserve the existing VERSION substitution and match
the direct substitution pattern used by the nearby `.transformers[0]` update.
- Around line 132-136: Replace the fragile shell quote-splicing in the yq
expressions within the release script, including the repeated occurrences around
the metadata, service account, and extra-label updates, with yq’s env(NAME)
variable access. First verify that the yq version pinned by validate_inputs
supports the required env() string-concatenation semantics, then apply the
consistent expression style to all affected VERSION and VERSION_DASHED usages.
- Around line 189-190: Replace the hard-coded tags[2] and tags[3] assignments in
the release update flow with the same pattern-based sub() approach used by
create_release_kustomization, targeting the intended tag values by their
existing content rather than array position while preserving the VERSION and
timestamp substitutions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 4d1dca25-8ef9-46ed-95ee-ace21a4cbd19

📥 Commits

Reviewing files that changed from the base of the PR and between a1cba46 and 6995c2d.

📒 Files selected for processing (4)
  • scripts/start-y-stream-release.sh
  • scripts/templates/release-kustomization.yaml
  • scripts/templates/release-plan-admission-prod.yaml
  • scripts/templates/release-plan-admission-stage.yaml

Comment on lines +106 to +114
prepare_stackrox_mcp_branch() {
local branch="release-${VERSION}"

log "Fetching origin in stackrox-mcp..."
git -C "${SCRIPT_DIR}/.." fetch origin

log "Creating branch ${branch} from origin/main..."
git -C "${SCRIPT_DIR}/.." checkout -b "${branch}" origin/main
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

No rerun-safety for release branch creation in either repo workflow. Both prepare_stackrox_mcp_branch and prepare_konflux_data_branch use git checkout -b, which fails if the branch already exists locally — e.g. after a dry-run followed by a real run, or after any mid-script failure that leaves the branch behind. Under set -e this aborts the whole release script.

  • scripts/start-y-stream-release.sh#L106-L114: switch to git checkout -B "${branch}" origin/main (or check git rev-parse --verify first) so a rerun resets the branch to origin/main instead of failing.
  • scripts/start-y-stream-release.sh#L155-L163: apply the same fix for agentic-suite-release-${VERSION_DASHED}.

Note -B discards any local, unpushed commits on a pre-existing branch of the same name — acceptable for a re-run of "start release," but worth calling out explicitly in a comment.

📍 Affects 1 file
  • scripts/start-y-stream-release.sh#L106-L114 (this comment)
  • scripts/start-y-stream-release.sh#L155-L163
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/start-y-stream-release.sh` around lines 106 - 114, The release branch
creation in prepare_stackrox_mcp_branch and prepare_konflux_data_branch is not
rerun-safe. In scripts/start-y-stream-release.sh lines 106-114 and 155-163,
replace each git checkout -b invocation with checkout -B using the same branch
name and origin/main base, and add a brief comment noting that reruns reset and
discard local unpushed commits on the existing release branch.

Comment on lines +132 to +136
yq -i --yaml-compact-seq-indent '.metadata.labels."appstudio.openshift.io/application" = "agentic-cluster-security-suite-'"${VERSION_DASHED}"'"' "${file}"
yq -i --yaml-compact-seq-indent '.metadata.labels."appstudio.openshift.io/component" = "acs-mcp-server-'"${VERSION_DASHED}"'"' "${file}"
yq -i --yaml-compact-seq-indent '.spec.taskRunTemplate.serviceAccountName = "build-pipeline-acs-mcp-server-'"${VERSION_DASHED}"'"' "${file}"
yq -i --yaml-compact-seq-indent '(.spec.params[] | select(.name == "extra-labels") | .value[0]) = "cpe=cpe:/a:redhat:agentic_cluster_security_suite:'"${VERSION}"'::el9"' "${file}"
done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider env(VAR) instead of string-concatenated yq expressions.

This quoting-concatenation pattern ('...'"${VERSION_DASHED}"'...') repeats at lines 185-190, 203-204, and 215. yq supports reading environment variables directly inside expressions (env(NAME)), which would avoid the fragile quote-splicing and make the expressions easier to read/maintain.

♻️ Example using env()
-        yq -i --yaml-compact-seq-indent '.metadata.labels."appstudio.openshift.io/application" = "agentic-cluster-security-suite-'"${VERSION_DASHED}"'"' "${file}"
+        yq -i --yaml-compact-seq-indent '.metadata.labels."appstudio.openshift.io/application" = "agentic-cluster-security-suite-" + env(VERSION_DASHED)' "${file}"

Please confirm env(VAR) string-concatenation semantics against the yq version pinned in validate_inputs before adopting broadly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/start-y-stream-release.sh` around lines 132 - 136, Replace the
fragile shell quote-splicing in the yq expressions within the release script,
including the repeated occurrences around the metadata, service account, and
extra-label updates, with yq’s env(NAME) variable access. First verify that the
yq version pinned by validate_inputs supports the required env()
string-concatenation semantics, then apply the consistent expression style to
all affected VERSION and VERSION_DASHED usages.

Comment on lines +189 to +190
yq -i '.spec.data.mapping.defaults.tags[2] = "'"${VERSION}"'"' "${target}"
yq -i '.spec.data.mapping.defaults.tags[3] = "'"${VERSION}"'-{{ timestamp }}"' "${target}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Hard-coded array indices are fragile.

tags[2]/tags[3] assume the template's tag ordering never changes; a future template edit would silently overwrite the wrong entries with no error. The sub()-based approach used in create_release_kustomization (line 203) is safer and more self-documenting.

♻️ Suggested pattern-based replacement
-    yq -i '.spec.data.mapping.defaults.tags[2] = "'"${VERSION}"'"' "${target}"
-    yq -i '.spec.data.mapping.defaults.tags[3] = "'"${VERSION}"'-{{ timestamp }}"' "${target}"
+    yq -i '.spec.data.mapping.defaults.tags |= map(sub("^X\.Y$", "'"${VERSION}"'"))' "${target}"
+    yq -i '.spec.data.mapping.defaults.tags |= map(sub("^X\.Y-\{\{ timestamp \}\}$", "'"${VERSION}"'-{{ timestamp }}"))' "${target}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
yq -i '.spec.data.mapping.defaults.tags[2] = "'"${VERSION}"'"' "${target}"
yq -i '.spec.data.mapping.defaults.tags[3] = "'"${VERSION}"'-{{ timestamp }}"' "${target}"
yq -i '.spec.data.mapping.defaults.tags |= map(sub("^X\.Y$", "'"${VERSION}"'"))' "${target}"
yq -i '.spec.data.mapping.defaults.tags |= map(sub("^X\.Y-\{\{ timestamp \}\}$", "'"${VERSION}"'-{{ timestamp }}"))' "${target}"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/start-y-stream-release.sh` around lines 189 - 190, Replace the
hard-coded tags[2] and tags[3] assignments in the release update flow with the
same pattern-based sub() approach used by create_release_kustomization,
targeting the intended tag values by their existing content rather than array
position while preserving the VERSION and timestamp substitutions.

cp "${TEMPLATE_DIR}/release-kustomization.yaml" "${release_dir}/kustomization.yaml"

local target="${release_dir}/kustomization.yaml"
yq -i '(.patches[0].patch | select(. == "*")) |= sub("release-X.Y", "release-'"${VERSION}"'")' "${target}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

select(. == "*") makes the patch substitution a permanent no-op.

.patches[0].patch is the literal multi-line Component patch text (never the string "*"), so the select filter never matches and sub("release-X.Y", ...) is never applied via |=. Every generated kustomization.yaml will ship the unresolved placeholder revision: release-X.Y instead of the real release branch, breaking the Component pointer for every release. Line 204's .transformers[0] |= sub(...) (no select) shows this was likely a stray leftover.

🐛 Proposed fix
-    yq -i '(.patches[0].patch | select(. == "*")) |= sub("release-X.Y", "release-'"${VERSION}"'")' "${target}"
+    yq -i '.patches[0].patch |= sub("release-X.Y", "release-'"${VERSION}"'")' "${target}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
yq -i '(.patches[0].patch | select(. == "*")) |= sub("release-X.Y", "release-'"${VERSION}"'")' "${target}"
yq -i '.patches[0].patch |= sub("release-X.Y", "release-'"${VERSION}"'")' "${target}"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/start-y-stream-release.sh` at line 203, Remove the `select(. == "*")`
filter from the `.patches[0].patch` update in the release-generation command,
and apply `sub("release-X.Y", ...)` directly to the patch text. Preserve the
existing VERSION substitution and match the direct substitution pattern used by
the nearby `.transformers[0]` update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants