-
Notifications
You must be signed in to change notification settings - Fork 1
chore(port): Port release scripts and renovate config to release #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mtodor
wants to merge
4
commits into
release-0.2
Choose a base branch
from
mtodor/port-release-script-and-renovate-config
base: release-0.2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
482b3af
chore(Konflux): Enable MintMaker auto-merge (#170)
mtodor 9720a27
chore(release): Add start Y release script (#179)
mtodor 1aca5bf
chore(release): Add prepare release script (#185)
mtodor 275d461
chore(CI): Split updates per day to allow smooth auto-merge process (…
mtodor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
| REPO_DIR="${SCRIPT_DIR}/.." | ||
| TEMPLATE_DIR="${SCRIPT_DIR}/templates" | ||
|
|
||
| VERSION="" | ||
| VERSION_DASHED="" | ||
| RELEASE_VERSION="" | ||
| RELEASE_VERSION_DASHED="" | ||
|
|
||
| usage() { | ||
| cat <<EOF | ||
| Usage: $(basename "$0") <version> | ||
|
|
||
| Prepare a patch release for an existing Y-stream release branch. | ||
|
|
||
| Discovers the next Z version from existing tags, creates a prepare branch, | ||
| updates Chart.yaml, and generates Konflux Release resource YAMLs for | ||
| stage and production. | ||
|
|
||
| Arguments: | ||
| version Y-stream version in X.Y format (e.g., 0.2, 1.1) | ||
|
|
||
| Example: | ||
| $(basename "$0") 0.2 | ||
| $(basename "$0") 1.1 | ||
| EOF | ||
| exit 0 | ||
| } | ||
|
|
||
| log() { | ||
| echo "==> $*" | ||
| } | ||
|
|
||
| error() { | ||
| echo "ERROR: $*" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| parse_args() { | ||
| local positional=() | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| -h|--help) | ||
| usage | ||
| ;; | ||
| -*) | ||
| error "Unknown option: $1" | ||
| ;; | ||
| *) | ||
| positional+=("$1") | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ ${#positional[@]} -ne 1 ]]; then | ||
| error "Expected 1 positional argument: <version>. Got ${#positional[@]}." | ||
| fi | ||
|
|
||
| export VERSION="${positional[0]}" | ||
| export VERSION_DASHED="${VERSION//./-}" | ||
| } | ||
|
|
||
| validate_inputs() { | ||
| if ! [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+$ ]]; then | ||
| error "Version must be in X.Y format (e.g., 0.2). Got: ${VERSION}" | ||
| fi | ||
|
|
||
| if ! command -v yq &>/dev/null; then | ||
| error "yq is required but not found in PATH" | ||
| fi | ||
|
|
||
| if ! command -v git &>/dev/null; then | ||
| error "git is required but not found in PATH" | ||
| fi | ||
|
|
||
| local yq_version | ||
| yq_version=$(yq --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') | ||
| if ! printf '%s\n' "4.52.1" "${yq_version}" | sort -V | head -n1 | grep -q "4.52.1"; then | ||
| error "yq version 4.52.1 or higher is required. Found: ${yq_version}" | ||
| fi | ||
|
|
||
| if [[ ! -d "${TEMPLATE_DIR}" ]]; then | ||
| error "Templates directory not found: ${TEMPLATE_DIR}" | ||
| fi | ||
|
|
||
| git -C "${REPO_DIR}" fetch origin | ||
| if ! git -C "${REPO_DIR}" rev-parse --verify "origin/release-${VERSION}" &>/dev/null; then | ||
| error "Release branch origin/release-${VERSION} does not exist. Run start-y-stream-release.sh first." | ||
| fi | ||
| } | ||
|
|
||
| checkout_release_branch() { | ||
| local branch="release-${VERSION}" | ||
|
|
||
| log "Checking out branch ${branch}..." | ||
| git -C "${REPO_DIR}" checkout "${branch}" | ||
| git -C "${REPO_DIR}" pull --ff-only origin "${branch}" | ||
| } | ||
|
|
||
| discover_next_version() { | ||
| local latest_tag | ||
| latest_tag=$(git -C "${REPO_DIR}" tag -l "${VERSION}.*" --sort=-version:refname | grep -E "^${VERSION}\.[0-9]+$" | head -1 || true) | ||
|
|
||
| if [[ -z "${latest_tag}" ]]; then | ||
| export RELEASE_VERSION="${VERSION}.0" | ||
| else | ||
| local patch | ||
| patch="${latest_tag##*.}" | ||
| export RELEASE_VERSION="${VERSION}.$((patch + 1))" | ||
| fi | ||
|
|
||
| export RELEASE_VERSION_DASHED="${RELEASE_VERSION//./-}" | ||
| log "Next release version: ${RELEASE_VERSION}" | ||
| } | ||
|
|
||
| create_prepare_branch() { | ||
| local branch="release-${RELEASE_VERSION_DASHED}-prepare" | ||
|
|
||
| # -B resets the branch if it already exists, so reruns discard local unpushed commits. | ||
| log "Creating branch ${branch}..." | ||
| git -C "${REPO_DIR}" checkout -B "${branch}" | ||
| } | ||
|
|
||
| update_chart_version() { | ||
| local chart="${REPO_DIR}/charts/stackrox-mcp/Chart.yaml" | ||
|
|
||
| if [[ ! -f "${chart}" ]]; then | ||
| error "Chart.yaml not found: ${chart}" | ||
| fi | ||
|
|
||
| log "Updating Chart.yaml to version ${RELEASE_VERSION}..." | ||
| yq -i '.version = env(RELEASE_VERSION)' "${chart}" | ||
| yq -i '.appVersion = env(RELEASE_VERSION)' "${chart}" | ||
| } | ||
|
|
||
| create_release_resources() { | ||
| local releases_dir="${REPO_DIR}/releases/${RELEASE_VERSION}" | ||
|
|
||
| log "Creating release resources in releases/${RELEASE_VERSION}/..." | ||
| mkdir -p "${releases_dir}" | ||
|
|
||
| export RELEASE_AUTHOR="${USER}" | ||
|
|
||
| create_release_file "stage" "${releases_dir}" | ||
| create_release_file "prod" "${releases_dir}" | ||
| } | ||
|
|
||
| create_release_file() { | ||
| export RELEASE_ENV="$1" | ||
| local output_dir="$2" | ||
| local template="${TEMPLATE_DIR}/release-resource.yaml" | ||
| local target="${output_dir}/agentic-cluster-security-suite-${VERSION_DASHED}--${RELEASE_VERSION_DASHED}--${RELEASE_ENV}.yaml" | ||
|
|
||
| log " Creating ${RELEASE_ENV} Release resource..." | ||
| cp "${template}" "${target}" | ||
|
|
||
| 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}" | ||
| yq -i '(.spec.data.mapping.defaults.tags[] | select(test("X\\.Y"))) |= sub("X\\.Y", env(VERSION))' "${target}" | ||
| yq -i '.spec.data.releaseNotes.topic |= sub("X\\.Y\\.Z", env(RELEASE_VERSION))' "${target}" | ||
| yq -i '.spec.data.releaseNotes.description |= sub("X\\.Y\\.Z", env(RELEASE_VERSION))' "${target}" | ||
| } | ||
|
|
||
| main() { | ||
| parse_args "$@" | ||
| validate_inputs | ||
|
|
||
| log "Preparing release for Y-stream ${VERSION}" | ||
|
|
||
| checkout_release_branch | ||
| discover_next_version | ||
| create_prepare_branch | ||
| update_chart_version | ||
| create_release_resources | ||
|
|
||
| log "" | ||
| log "Release preparation complete!" | ||
| log " Branch: release-${RELEASE_VERSION_DASHED}-prepare" | ||
| log " Chart.yaml: version=${RELEASE_VERSION}, appVersion=${RELEASE_VERSION}" | ||
| log " Stage: releases/${RELEASE_VERSION}/agentic-cluster-security-suite-${VERSION_DASHED}--${RELEASE_VERSION_DASHED}--stage.yaml" | ||
| log " Prod: releases/${RELEASE_VERSION}/agentic-cluster-security-suite-${VERSION_DASHED}--${RELEASE_VERSION_DASHED}--prod.yaml" | ||
| log "" | ||
| log "Review changes, then commit and push." | ||
| } | ||
|
|
||
| main "$@" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.