-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Implement automated version bump pipeline for patch and minor releases #262224
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
Changes from 24 commits
afe3388
26724b6
09bfe0c
18ce0b8
c62e910
fa54898
03a3d14
e7c4c47
a11f6eb
9da4e14
cee7a56
12a9995
79656fd
903b4a3
73c9dc6
db46af3
90116dc
262869e
d1b6962
e9ea46a
a2101f6
0286429
1b90a3d
b1dee98
73f4be6
c578a90
7e56730
39c65d0
87ef7cc
e5dac3a
6b4ef0c
0ee51bd
92c4474
6487ff7
28be97b
9d6664e
fae68f0
3056f42
5a8bc79
cb276fa
95db6e0
12dd587
f4799b3
4ec97de
6fca72c
573c55b
f0eea6a
edd521b
18d7f49
21b09c2
61a0a91
b54a148
292856d
ce17d2a
c65266e
0c3f3e5
df95533
532eb82
8a9f20c
de89fc9
7e3331f
6af1e8d
889d74f
6921668
6802232
7f212ca
b8212db
1967c7e
2d83907
e587733
a0c5940
e8f0b94
6f85a62
0c4ca16
536045e
382c6b7
1ebc729
6c4bd09
bbf02ec
19506e4
fe81eb1
e89f4d4
0a8e97d
eca89b1
e68eb1f
a158032
21b91db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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' | ||
|
TamerlanG marked this conversation as resolved.
Outdated
TamerlanG marked this conversation as resolved.
Outdated
|
||
| 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' | ||||||
|
||||||
| branch: 'main' | |
| branch: '${BRANCH}' |
| 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 | ||
|
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 | ||
|
TamerlanG marked this conversation as resolved.
Outdated
|
||
| agents: | ||
| image: family/kibana-ubuntu-2404 | ||
| imageProject: elastic-images-prod | ||
| provider: gcp | ||
| machineType: n2-standard-2 | ||
| 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 |
| 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 |
| 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 | ||
|
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" | ||
|
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 | ||
|
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 | ||
|
TamerlanG marked this conversation as resolved.
Outdated
|
||
| git commit -m "[version bump] Bump version to ${NEW_VERSION}" | ||
| git push origin "$branch" | ||
|
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" | ||
|
|
||
|
|
||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make the minor-flow insertions idempotent. On a retry after the first PR merged, Lines 38-41 add a second 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.jsonAlso applies to: 68-71 🤖 Prompt for AI Agents |
||
|
|
||
| # 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" | ||
|
macroscopeapp[bot] marked this conversation as resolved.
Outdated
|
||
| git push origin "$BRANCH" | ||
|
|
||
| echo "Branch '$BRANCH' created and pushed to origin" | ||
Uh oh!
There was an error while loading. Please reload this page.