Skip to content

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

Open
mtodor wants to merge 2 commits into
mainfrom
mtodor/add-script-to-start-y-release
Open

chore(release): Add start Y release script#179
mtodor wants to merge 2 commits 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

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

E2E Test Results

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

=== Evaluation Summary ===

  ✓ cve-cluster-does-exist (assertions: 3/3)
  ✓ cve-clusters-general (assertions: 3/3)
  ✓ cve-cluster-does-not-exist (assertions: 3/3)
  ✓ cve-cluster-list (assertions: 3/3)
  ✓ rhsa-not-supported (assertions: 2/2)
  ✓ cve-detected-workloads (assertions: 3/3)
  ~ cve-log4shell (assertions: 2/3)
      - ToolsUsed: Required tool not called: server=stackrox-mcp, tool=, pattern=get_deployments_for_cve
  ✓ list-clusters (assertions: 3/3)
  ✓ cve-detected-clusters (assertions: 3/3)
  ✗ cve-nonexistent (assertions: 3/3)
      one or more verification steps failed
  ✓ cve-multiple (assertions: 3/3)

Tasks:      10/11 passed (90.91%)
Assertions: 31/32 passed (96.88%)
Tokens:     ~50322 (estimate - excludes system prompt & cache)
MCP schemas: ~12562 (included in token total)
Agent used tokens:
  Input:  10542 tokens
  Output: 20324 tokens
Judge used tokens:
  Input:  91434 tokens
  Output: 43351 tokens

@codecov-commenter

codecov-commenter commented Jul 28, 2026

Copy link
Copy Markdown

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
380 2 378 12
View the full list of 2 ❄️ flaky test(s)
::policy 1

Flake rate in main: 100.00% (Passed 0 times, Failed 84 times)

Stack Traces | 0s run time
- test violation 1
- test violation 2
- test violation 3
::policy 4

Flake rate in main: 100.00% (Passed 0 times, Failed 84 times)

Stack Traces | 0s run time
- testing multiple alert violation messages 1
- testing multiple alert violation messages 2
- testing multiple alert violation messages 3

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added an automated “Y-stream” release workflow that prepares staged and production release branches.
    • Added dry-run mode to generate and commit changes locally without pushing remotely.
    • Added templates for production and stage ReleasePlanAdmission, plus release kustomization with versioned revision and transformer updates.
  • Validation
    • Added stricter release input/tool checks (including version format and tool version constraints) and configuration validation before completing the workflow.

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 release arguments, validates tools, directories, version format, and yq; sequences both repository 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
Creates the Konflux release-data branch, runs tenant configuration validation through build-single.sh, then commits and conditionally pushes the 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 is concise and clearly identifies the main change: adding the Y-stream release script.
Description check ✅ Passed The description is detailed and directly describes the script and templates added by 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 thread scripts/start-y-stream-release.sh
Comment thread scripts/start-y-stream-release.sh Outdated
Comment thread scripts/start-y-stream-release.sh Outdated
Comment thread scripts/start-y-stream-release.sh Outdated
@mtodor
mtodor force-pushed the mtodor/add-script-to-start-y-release branch from 6995c2d to d8d039e Compare July 29, 2026 09:00

@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: 2

🤖 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: Update prepare_stackrox_mcp_branch and the Konflux
checkout flow to run git status --porcelain and abort before either checkout
when the respective worktree is non-empty. In the release staging step, replace
broad git add -A with explicit staging of only the expected generated Konflux
files and directories.

In `@scripts/templates/release-plan-admission-stage.yaml`:
- Around line 39-42: Replace the mutable production branch revision for
release-service-catalog with an immutable commit SHA or tag in
scripts/templates/release-plan-admission-stage.yaml at lines 39-42 and
scripts/templates/release-plan-admission-prod.yaml at lines 39-42, keeping both
imported pipeline references pinned consistently.
🪄 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: 3d8ef9b6-53f7-4be7-8fc8-96ca05cc80a4

📥 Commits

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

📒 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 thread scripts/start-y-stream-release.sh
Comment thread scripts/templates/release-plan-admission-stage.yaml
fi

log "Adding release-${VERSION} to parent kustomization.yaml..."
yq -i '.resources += ["release-" + env(VERSION)]' "${parent_kustomization}"

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.

+= blindly appends without checking if the entry already exists. If the script is re-run after a previous PR was merged (e.g. to fix a typo), checkout -B resets to origin/main (which now contains the merged entry), then this appends a duplicate. kustomize will reject the duplicate resource declaration with an "already visited" error, blocking the release.

Consider guarding with something like:

yq -i '.resources |= (. + ["release-" + env(VERSION)] | unique)' "${parent_kustomization}"

yq -i '.spec.applications[0] = "agentic-cluster-security-suite-" + env(VERSION_DASHED)' "${target}"
yq -i '.spec.data.releaseNotes.product_version = env(VERSION)' "${target}"
yq -i '.spec.data.mapping.components[0].name = "acs-mcp-server-" + env(VERSION_DASHED)' "${target}"
yq -i '(.spec.data.mapping.defaults.tags[] | select(test("X.Y"))) |= sub("X.Y", env(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.

The dot in "X.Y" is an unescaped regex wildcard — it matches any character between X and Y, not just a literal period. Compare with line 136 which correctly escapes:

select(test("X\\.Y"))) |= sub("X\\.Y", env(VERSION))

Same issue on line 204 with sub("release-X.Y", ...). All call sites should use consistent escaping.

local branch="agentic-suite-release-${VERSION_DASHED}"

log "Committing all changes in konflux-release-data..."
git -C "${KONFLUX_DATA_REPO}" add -A

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.

Suggestion: This operates on a user-provided path to a separately cloned repository. git add -A stages everything including untracked files (editor swap files, test outputs, notes). Line 145 in the stackrox-mcp part correctly uses targeted staging (git add .tekton/). Consider staging only the specific paths the script modifies:

git -C "${KONFLUX_DATA_REPO}" add \
    config/kflux-prd-rh02.0fk9.p1/product/ReleasePlanAdmission/ \
    tenants-config/cluster/kflux-prd-rh02/tenants/agentic-cluster-security-suite-tenant/


# -B resets the branch if it already exists, so reruns discard local unpushed commits.
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.

Suggestion: The comment on line 113 documents this as intentional, which is good. But if someone made manual adjustments to the branch and re-runs the script, their work is silently lost. A pre-check for unpushed commits with a warning would make re-runs safer:

if git -C "${repo}" log --oneline "origin/main..${branch}" 2>/dev/null | grep -q .; then
    log "WARNING: Branch ${branch} has unpushed commits that will be discarded"
fi

yq -i --yaml-compact-seq-indent '.metadata.labels."appstudio.openshift.io/application" = "agentic-cluster-security-suite-" + env(VERSION_DASHED)' "${file}"
yq -i --yaml-compact-seq-indent '.metadata.labels."appstudio.openshift.io/component" = "acs-mcp-server-" + env(VERSION_DASHED)' "${file}"
yq -i --yaml-compact-seq-indent '.spec.taskRunTemplate.serviceAccountName = "build-pipeline-acs-mcp-server-" + env(VERSION_DASHED)' "${file}"
yq -i --yaml-compact-seq-indent '(.spec.params[] | select(.name == "extra-labels") | .value[] | select(test("X\\.Y"))) |= sub("X\\.Y", env(VERSION))' "${file}"

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.

Good — the escaped dot here (X\\.Y) is the correct pattern. The other call sites (lines 191, 204) should match this.

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.

3 participants