Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
afe3388
feat: add initial template from release-eng team
TamerlanG Apr 1, 2026
26724b6
wip: bump version jobs
TamerlanG Apr 1, 2026
09bfe0c
feat: implement versions.json bump script for patch, minor, and major…
TamerlanG Apr 2, 2026
18ce0b8
feat: add script to create new release branch off main
TamerlanG Apr 5, 2026
c62e910
feat: make the snapshot build triggers synchronous
TamerlanG Apr 5, 2026
fa54898
feat: implement full patch version bump pipeline workflow
TamerlanG Apr 7, 2026
03a3d14
fix: trigger the dra snapshot and staging at main
TamerlanG Apr 7, 2026
e7c4c47
feat: implement minor/major version bump pipeline workflow
TamerlanG Apr 7, 2026
a11f6eb
wip
TamerlanG Apr 7, 2026
9da4e14
revert changes to snapshot build
TamerlanG Apr 7, 2026
cee7a56
wip: refactor trigger es build and promote
TamerlanG Apr 8, 2026
12a9995
wip
TamerlanG Apr 8, 2026
79656fd
uncomment code
TamerlanG Apr 8, 2026
903b4a3
refactor: extract bump_versions_json.sh into functions and always tar…
TamerlanG Apr 8, 2026
73c9dc6
Add wait_for_pr_merge utility to poll until auto-merge PRs are merged
TamerlanG Apr 8, 2026
db46af3
chore: add agent config to the pipeline
TamerlanG Apr 8, 2026
90116dc
refactor: get the old version directly
TamerlanG Apr 8, 2026
262869e
fix the commit logic
TamerlanG Apr 9, 2026
d1b6962
chore: remove redundant file and add agent info to the update label c…
TamerlanG Apr 9, 2026
e9ea46a
chore: remove codeowners change
TamerlanG Apr 9, 2026
a2101f6
feat: pipeline to update pipeline resource definitions for minor rele…
TamerlanG Apr 9, 2026
0286429
feat: allow overriding target branch for version bump PR and enable b…
TamerlanG Apr 9, 2026
1b90a3d
feat: notify #mission-control when Kibana is branched but version bum…
TamerlanG Apr 9, 2026
b1dee98
Merge branch 'main' into feat/dra-bump-pipeline
TamerlanG Apr 9, 2026
73f4be6
Add run_skipped_test helper to unskip/reskip create_test_archives bef…
TamerlanG Apr 9, 2026
c578a90
chore: fix small errors detected by ai
TamerlanG Apr 9, 2026
7e56730
Update .buildkite/pipelines/version_bump/trigger_es_build_and_promote…
TamerlanG Apr 9, 2026
39c65d0
Update .buildkite/scripts/steps/version_bump/bump.sh
TamerlanG Apr 9, 2026
87ef7cc
Update .buildkite/scripts/steps/version_bump/pipeline.ts
TamerlanG Apr 9, 2026
e5dac3a
fix: add check that workflow env exists
TamerlanG Apr 9, 2026
6b4ef0c
Update .buildkite/scripts/steps/version_bump/update_release_branch.sh
TamerlanG Apr 9, 2026
0ee51bd
small fixes according to claude review
TamerlanG Apr 9, 2026
92c4474
Merge branch 'main' into feat/dra-bump-pipeline
TamerlanG Apr 10, 2026
6487ff7
refactor: check if the initial_app_data file exists
TamerlanG Apr 10, 2026
28be97b
refactor: comments, fix dra builds, and minor workflow order
TamerlanG Apr 10, 2026
9d6664e
Remove stale 'blocked' state notification from version bump pipeline
TamerlanG Apr 10, 2026
fae68f0
fix: proper path to the file
TamerlanG Apr 12, 2026
3056f42
Merge branch 'main' into feat/dra-bump-pipeline
TamerlanG Apr 13, 2026
5a8bc79
[release branch setup] Append * @kibanamachine to CODEOWNERS to preve…
TamerlanG Apr 13, 2026
cb276fa
Merge branch 'main' into feat/dra-bump-pipeline
TamerlanG Apr 14, 2026
95db6e0
refactor: trigger es snapshot and promote with artifact upload
TamerlanG Apr 14, 2026
12dd587
refactor: run es build and promote on main for minor
TamerlanG Apr 14, 2026
f4799b3
comment out the steps to test es build and promote
TamerlanG Apr 14, 2026
4ec97de
fix: add a depends_on
TamerlanG Apr 14, 2026
6fca72c
fix typo
TamerlanG Apr 14, 2026
573c55b
get the metadata
TamerlanG Apr 14, 2026
f0eea6a
revert comments
TamerlanG Apr 14, 2026
edd521b
Add DRY_RUN support to version bump pipeline scripts
TamerlanG Apr 14, 2026
18d7f49
move pipelines around
TamerlanG Apr 15, 2026
21b09c2
Merge branch 'main' into feat/dra-bump-pipeline
TamerlanG Apr 16, 2026
61a0a91
Merge branch 'main' into feat/dra-bump-pipeline
TamerlanG Apr 27, 2026
b54a148
remove premtible and spot zones
TamerlanG Apr 27, 2026
292856d
Merge branch 'main' into feat/dra-bump-pipeline
TamerlanG Apr 28, 2026
ce17d2a
Merge branch 'main' into feat/dra-bump-pipeline
TamerlanG Apr 30, 2026
c65266e
Merge branch 'main' into feat/dra-bump-pipeline
TamerlanG May 4, 2026
0c3f3e5
fix: run bootstrap for this job
TamerlanG May 4, 2026
df95533
feat: set dry runs for everything
TamerlanG May 4, 2026
532eb82
fix: use kibana ubuntu 24
TamerlanG May 4, 2026
8a9f20c
fix: add sparse checkout
TamerlanG May 4, 2026
de89fc9
fix orderings
TamerlanG May 4, 2026
7e3331f
use n2 machines instead
TamerlanG May 4, 2026
6af1e8d
fix: branch out of the correct branch
TamerlanG May 4, 2026
889d74f
source setup_node to install proper node version
TamerlanG May 4, 2026
6921668
test the label changes
TamerlanG May 4, 2026
6802232
use n2 machine
TamerlanG May 4, 2026
7f212ca
remove reconcile labeling
TamerlanG May 4, 2026
b8212db
uncomment the minor path an simplify things
TamerlanG May 4, 2026
1967c7e
uncomment line
TamerlanG May 4, 2026
2d83907
improve the dry run handling
TamerlanG May 5, 2026
e587733
add the wait
TamerlanG May 5, 2026
a0c5940
feat: simply gate the triggers instead of skipping them
TamerlanG May 5, 2026
e8f0b94
feat(version_bump): dry-run + create-if-missing for update_label_color
TamerlanG May 5, 2026
6f85a62
removet the depends on
TamerlanG May 5, 2026
0c4ca16
add a wait
TamerlanG May 5, 2026
536045e
test: remove the depends on
TamerlanG May 5, 2026
382c6b7
try skipping the job instead
TamerlanG May 5, 2026
1ebc729
use if statements instead
TamerlanG May 5, 2026
6c4bd09
refactor for better debugging experience
TamerlanG May 5, 2026
bbf02ec
fix: prevent wait steps from being deduplicated
TamerlanG May 5, 2026
19506e4
Merge branch 'main' into feat/dra-bump-pipeline
delanni May 6, 2026
fe81eb1
run all tests
TamerlanG May 6, 2026
e89f4d4
remove hardcoded dry runs
TamerlanG May 6, 2026
0a8e97d
Merge branch 'main' into feat/dra-bump-pipeline
TamerlanG May 6, 2026
eca89b1
remove comment
TamerlanG May 6, 2026
e68eb1f
fix ordering of tests
TamerlanG May 6, 2026
a158032
fix: also commit the snapshot fix
TamerlanG May 6, 2026
21b91db
Merge branch 'main' into feat/dra-bump-pipeline
TamerlanG May 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .buildkite/pipelines/version_bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ notify:
Workflow: `${WORKFLOW}`
${BUILDKITE_BUILD_URL}
if: build.state == "blocked"
- slack:
channels:
- '#mission-control'
message: |
Kibana has been bumped to `${NEW_VERSION}` on branch `${BRANCH}` and a DRA build has begun.
Build: ${BUILDKITE_BUILD_URL}
if: build.state == "passed"

steps:
# TODO: replace this block step by real version bump logic
- block: 'Ready to fetch for DRA artifacts?'
prompt: |
Unblock when your team is ready to proceed.
- command: .buildkite/scripts/version_bump/bump.sh
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Outdated
label: Bump version

Trigger parameters:
- NEW_VERSION: ${NEW_VERSION}
- BRANCH: ${BRANCH}
- WORKFLOW: ${WORKFLOW}
key: block-get-dra-artifacts
blocked_state: running
- wait

Comment thread
TamerlanG marked this conversation as resolved.
- label: 'Fetch DRA Artifacts'
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
key: fetch-dra-artifacts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- name: 'Bump package.json versions'
key: bump-package-json-versions
command: .buildkite/scripts/steps/version_bump/bump_package_json_versions.sh
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n4-standard-4
preemptible: true
Comment thread
TamerlanG marked this conversation as resolved.
Outdated
spotZones: us-central1-f,us-central1-c,us-central1-a
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
steps:
- name: 'Bump package.json versions (to main)'
key: bump-package-json-versions-to-main
command: .buildkite/scripts/steps/version_bump/bump_package_json_versions.sh
env:
OVERRIDE_BRANCH: main
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n4-standard-4
preemptible: true
spotZones: us-central1-f,us-central1-c,us-central1-a
11 changes: 11 additions & 0 deletions .buildkite/pipelines/version_bump/bump_versions_json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- name: 'Bump versions.json'
key: bump-versions-json
command: .buildkite/scripts/steps/version_bump/bump_versions_json.sh
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n4-standard-4
preemptible: true
spotZones: us-central1-f,us-central1-c,us-central1-a
4 changes: 4 additions & 0 deletions .buildkite/pipelines/version_bump/create_new_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- name: 'Create new release branch'
key: create-new-branch
command: .buildkite/scripts/steps/version_bump/create_new_branch_of_main.sh
4 changes: 4 additions & 0 deletions .buildkite/pipelines/version_bump/ensure_version_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- name: 'Ensure version label exists'
key: ensure-version-label
command: .buildkite/scripts/steps/version_bump/ensure_version_label.sh
4 changes: 4 additions & 0 deletions .buildkite/pipelines/version_bump/notify_branch_created.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- name: 'Notify Slack: branch created'
key: notify-branch-created
command: .buildkite/scripts/steps/version_bump/notify_branch_created.sh
4 changes: 4 additions & 0 deletions .buildkite/pipelines/version_bump/reconcile_pr_labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- name: 'Reconcile PR Labels'
key: reconcile-pr-labels
command: .buildkite/scripts/steps/version_bump/reconcile_pr_labels.sh
7 changes: 7 additions & 0 deletions .buildkite/pipelines/version_bump/trigger_dra_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
steps:
- name: Trigger DRA Snapshot Build
key: trigger-dra-snapshot
trigger: kibana-artifacts-snapshot
async: false
build:
branch: 'main'
Comment thread
TamerlanG marked this conversation as resolved.
Outdated
Comment thread
TamerlanG marked this conversation as resolved.
Outdated
7 changes: 7 additions & 0 deletions .buildkite/pipelines/version_bump/trigger_dra_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
steps:
- name: Trigger DRA Staging Build
key: trigger-dra-staging
trigger: kibana-artifacts-staging
async: false
build:
branch: 'main'

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

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

This trigger always builds DRA staging from 'main', which conflicts with the workflow logic that varies behavior based on BRANCH. If staging should validate the release branch, pass the release branch (e.g., BRANCH env var) rather than hardcoding 'main'.

Suggested change
branch: 'main'
branch: '${BRANCH}'

Copilot uses AI. Check for mistakes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
steps:
# run the bash files directly and only run the build and promote, because verify will fail.
# TODO: Ask @alex if this would work, especially because the meta data get happens in two separate bash files.

# Step 1: Run the ES Snapshot Build
- command: .buildkite/scripts/steps/es_snapshots/build.sh
Comment thread
TamerlanG marked this conversation as resolved.
Outdated
label: Build ES Snapshot
timeout_in_minutes: 30
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
localSsds: 1
localSsdInterface: nvme
machineType: c2-standard-8
diskSizeGb: 130

# Step 2: Run the ES Promote
- label: Promote Snapshot
command: .buildkite/scripts/steps/es_snapshots/promote.sh
depends_on: build-es-snapshot
Comment thread
TamerlanG marked this conversation as resolved.
Outdated
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n2-standard-2
11 changes: 11 additions & 0 deletions .buildkite/pipelines/version_bump/update_label_color.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- name: 'Update Label Color'
key: update-label-color
command: .buildkite/scripts/steps/version_bump/update_label_color.sh
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n4-standard-4
preemptible: true
spotZones: us-central1-f,us-central1-c,us-central1-a
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- name: 'Update pipeline resource definitions'
key: update-pipeline-resource-definitions
command: .buildkite/scripts/steps/version_bump/update_pipeline_resource_definitions.sh
agents:
image: family/kibana-ubuntu-2404
imageProject: elastic-images-prod
provider: gcp
machineType: n4-standard-4
preemptible: true
spotZones: us-central1-f,us-central1-c,us-central1-a
4 changes: 4 additions & 0 deletions .buildkite/pipelines/version_bump/update_release_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- name: 'Update release branch config'
key: update-release-branch
command: .buildkite/scripts/steps/version_bump/update_release_branch.sh
7 changes: 7 additions & 0 deletions .buildkite/scripts/steps/version_bump/bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -euo pipefail

# TODO: If the logic is simple within the piplein.ts file, then remove that layer of abstraction.
ts-node .buildkite/scripts/version_bump/pipeline.ts | buildkite-agent pipeline upload
Comment thread
TamerlanG marked this conversation as resolved.
Outdated

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env bash

set -euo pipefail

source "$(dirname "$0")/wait_for_pr_merge.sh"

branch_to_merge_into="${OVERRIDE_BRANCH:-$BRANCH}"

old_version=""
store_old_version() {
old_version=$(jq -r '.version' package.json)
echo "Current version: $old_version"
echo "New version: $NEW_VERSION"

buildkite-agent meta-data set "OLD_VERSION" "$old_version"
}

update_package_json_version() {
echo --- Bump package.json versions
sed -i "s/\"version\": \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\": \"${NEW_VERSION}\"/g" package.json
sed -i "s/\"version\": \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\": \"${NEW_VERSION}\"/g" x-pack/package.json
}

update_initial_app_data() {
echo --- Bump initial_app_data kibanaVersion
local target="x-pack/solutions/search/plugins/enterprise_search/common/__mocks__/initial_app_data.ts"
Comment thread
TamerlanG marked this conversation as resolved.
sed -i "s/kibanaVersion: '[0-9]\+\.[0-9]\+\.[0-9]\+'/kibanaVersion: '${NEW_VERSION}'/" "$target"
}

update_kibana_migrator_utils() {
echo --- Bump BASELINE_ELASTICSEARCH_VERSION
local target="src/core/server/integration_tests/saved_objects/migrations/kibana_migrator_archive_utils.ts"
sed -i "s/BASELINE_ELASTICSEARCH_VERSION = '[0-9]\+\.[0-9]\+\.[0-9]\+'/BASELINE_ELASTICSEARCH_VERSION = '${NEW_VERSION}'/" "$target"
}

delete_baseline_archives() {
echo --- Deleting baseline archives
local archive_dir="src/core/server/integration_tests/saved_objects/migrations/archives"
find "$archive_dir" -type f -name "${old_version}_baseline_*.zip" -delete
}

store_old_version

update_package_json_version

# If branch is 8.19, skip updating initial_app_data
if [[ "$BRANCH" != "8.19" ]]; then
Comment thread
TamerlanG marked this conversation as resolved.
Outdated
update_initial_app_data
fi

update_kibana_migrator_utils

delete_baseline_archives

# Run integration tests to update snapshots
node scripts/jest_integration.js -u src/core/server/integration_tests/saved_objects/migrations/group1/create_test_archives.test.ts
node scripts/jest_integration.js -u src/core/server/integration_tests/saved_objects/migrations/group1/v2_migration.test.ts


echo --- Committing version bump changes
git config --global user.name kibanamachine
git config --global user.email '42973632+kibanamachine@users.noreply.github.com'

head_branch="bump-versions-$(date +%F_%H-%M-%S)"
git checkout -b "$head_branch"
git add package.json x-pack/package.json x-pack/solutions/search/plugins/enterprise_search/common/__mocks__/initial_app_data.ts src/core/server/integration_tests/saved_objects/migrations/kibana_migrator_archive_utils.ts src/core/server/integration_tests/saved_objects/migrations/archives
Comment thread
TamerlanG marked this conversation as resolved.
Outdated
git commit -m "[version bump] Bump version to ${NEW_VERSION}"
git push origin "$branch"
Comment thread
TamerlanG marked this conversation as resolved.
Outdated

prUrl=$(gh pr create --repo elastic/kibana --base "$branch_to_merge_into" --head "$head_branch" --title "[bump version] $(date +%F) Bump package.json versions to ${NEW_VERSION}" --body "Generated by $BUILDKITE_BUILD_URL" --label "release_note:skip" --label "backport:skip")
echo "Opened PR: $prUrl"

gh pr merge --repo elastic/kibana --auto --squash --delete-branch "$prUrl"

wait_for_pr_merge "$prUrl"


124 changes: 124 additions & 0 deletions .buildkite/scripts/steps/version_bump/bump_versions_json.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/usr/bin/env bash

set -euo pipefail

source "$(dirname "$0")/wait_for_pr_merge.sh"

# Always target main, even when the pipeline runs on another branch
git fetch origin main
git checkout main

# --- Functions ---

update_patch_versions_json() {
echo "Patch bump: updating version for branch '$BRANCH' to '$NEW_VERSION'"

jq --arg version "$NEW_VERSION" --arg branch "$BRANCH" \
'(.versions[] | select(.branch == $branch)).version = $version' \
versions.json > versions.json.tmp && mv versions.json.tmp versions.json
}

update_minor_versions_json() {
local major minor next_minor

major=$(echo "$NEW_VERSION" | cut -d. -f1)
minor=$(echo "$NEW_VERSION" | cut -d. -f2)
next_minor=$((minor + 1))
NEXT_DEV_VERSION="${major}.${next_minor}.0"

echo "Minor bump: adding branch '$BRANCH' with version '$NEW_VERSION'"
echo "Next dev version for main: $NEXT_DEV_VERSION"

# 1. Bump main's version to the next dev version
jq --arg nextVersion "$NEXT_DEV_VERSION" \
'(.versions[] | select(.branch == "main")).version = $nextVersion' \
versions.json > versions.json.tmp && mv versions.json.tmp versions.json

# 2. Insert a new release entry for the new branch (after main)
jq --arg version "$NEW_VERSION" --arg branch "$BRANCH" \
'.versions |= [.[0]] + [{"version": $version, "branch": $branch, "branchType": "release"}] + .[1:]' \
versions.json > versions.json.tmp && mv versions.json.tmp versions.json
Comment on lines +41 to +44

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.

⚠️ Potential issue | 🟠 Major

Make the minor-flow insertions idempotent.

On a retry after the first PR merged, Lines 38-41 add a second versions.json entry for the same release branch and Lines 68-71 add the same branch to targetBranchChoices again. That leaves both tooling files malformed for subsequent runs.

Suggested fix
   jq --arg version "$NEW_VERSION" --arg branch "$BRANCH" \
-    '.versions |= [.[0]] + [{"version": $version, "branch": $branch, "branchType": "release"}] + .[1:]' \
+    '.versions |= (
+      if any(.[]; .branch == $branch) then
+        map(if .branch == $branch then .version = $version | .branchType = "release" else . end)
+      else
+        [.[0]] + [{"version": $version, "branch": $branch, "branchType": "release"}] + .[1:]
+      end
+    )' \
     versions.json > versions.json.tmp && mv versions.json.tmp versions.json
...
   jq --arg branch "$BRANCH" \
-    '.targetBranchChoices |= [.[0]] + [$branch] + .[1:]' \
+    '.targetBranchChoices |= (
+      if index($branch) then .
+      else [.[0]] + [$branch] + .[1:]
+      end
+    )' \
     .backportrc.json > .backportrc.json.tmp && mv .backportrc.json.tmp .backportrc.json

Also applies to: 68-71

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.buildkite/scripts/steps/version_bump/bump_versions_json.sh around lines 38
- 41, The jq insertion into .versions (using .versions |= [.[0]] + [{"version":
$version, "branch": $branch, "branchType": "release"}] + .[1:]) and the similar
insertion into .targetBranchChoices must be made idempotent: before adding,
check whether an entry with branch == $BRANCH (or the branch string) already
exists and only perform the append when absent. Update the script's jq
invocations that use the variables NEW_VERSION and BRANCH so they test
membership (e.g., any(.versions[]; .branch == $branch) and
any(.targetBranchChoices[]; . == $branch)) and skip the insertion when true,
ensuring repeated runs don’t create duplicate entries.


# 3. Prune oldest same-major minor if there are more than 2 release entries for this major
local same_major_count
same_major_count=$(jq --arg major "$major" \
'[.versions[] | select(.branchType == "release" and (.branch | startswith($major + ".")))] | length' \
versions.json)

if [ "$same_major_count" -gt 2 ]; then
echo "Found $same_major_count release entries for major $major, pruning oldest"

local oldest_branch
oldest_branch=$(jq -r --arg major "$major" \
'[.versions[] | select(.branchType == "release" and (.branch | startswith($major + ".")))]
| sort_by(.branch | split(".")[1] | tonumber)
| .[0].branch' \
versions.json)

echo "Removing oldest branch: $oldest_branch"

jq --arg oldBranch "$oldest_branch" \
'.versions |= map(select(.branch != $oldBranch))' \
versions.json > versions.json.tmp && mv versions.json.tmp versions.json
fi
}

update_backportrc_json() {
# 1. Add the new branch to targetBranchChoices right after "main"
jq --arg branch "$BRANCH" \
'.targetBranchChoices |= [.[0]] + [$branch] + .[1:]' \
.backportrc.json > .backportrc.json.tmp && mv .backportrc.json.tmp .backportrc.json

# 2. Update branchLabelMapping: replace the old main version pattern with the next dev version
# Match the key that maps to "main" and looks like "^v9.4.0$" (not the generic regex pattern)
jq --arg nextVersion "$NEXT_DEV_VERSION" \
'.branchLabelMapping |= with_entries(
if .value == "main" and (.key | startswith("^v")) and (.key | endswith("$")) and (.key | contains("(") | not)
then .key = ("^v" + $nextVersion + "$")
else .
end
)' \
.backportrc.json > .backportrc.json.tmp && mv .backportrc.json.tmp .backportrc.json
}

# --- Main ---

echo --- Bump versions.json versions

FILES_TO_COMMIT="versions.json"

if [ "$WORKFLOW" = "patch" ]; then
update_patch_versions_json

elif [ "$WORKFLOW" = "minor" ]; then
update_minor_versions_json
update_backportrc_json
FILES_TO_COMMIT="versions.json .backportrc.json"

else
echo "Error: Unknown WORKFLOW '$WORKFLOW'. Expected 'patch' or 'minor'."
exit 1
fi

echo "Updated versions.json successfully"
cat versions.json

echo --- Committing version bump changes

git config --global user.name kibanamachine
git config --global user.email '42973632+kibanamachine@users.noreply.github.com'

branch="bump-versions-json$(date +%F_%H-%M-%S)"
git checkout -b "$branch"
git add $FILES_TO_COMMIT
git commit -m "[versions.json bump] Bump versions.json to ${NEW_VERSION}"

git push origin "$branch"

prUrl=$(gh pr create --repo elastic/kibana --base main --head "$branch" --title "[Auto version bump] $(date +%F) Bump versions.json to ${NEW_VERSION}" --body "Generated by $BUILDKITE_BUILD_URL" --label "release_note:skip" --label "backport:skip")
echo "Opened PR: $prUrl"

gh pr merge --repo elastic/kibana --auto --squash --delete-branch "$prUrl"

wait_for_pr_merge "$prUrl"

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -euo pipefail

echo --- Create new branch off main

echo "Creating branch '$BRANCH' from main"

git config --global user.name kibanamachine
git config --global user.email '42973632+kibanamachine@users.noreply.github.com'

git checkout main
git checkout -b "$BRANCH"
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Outdated
git push origin "$BRANCH"

echo "Branch '$BRANCH' created and pushed to origin"
Loading
Loading