From 22e0945107732fe009b8ff229196d6b619481ccb Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Tue, 7 Apr 2026 15:50:42 +1200 Subject: [PATCH 1/2] [ML] Automate version bump in CI pipeline Replace the manual block step in the version-bump pipeline with an automated step that: 1. Checks out the target branch 2. Updates elasticsearchVersion in gradle.properties to $NEW_VERSION 3. Commits as elasticsearchmachine 4. Pushes directly to the branch (no PR needed) Follows the same pattern as Elasticsearch's automated Lucene snapshot updates (.buildkite/scripts/lucene-snapshot/update-es-snapshot.sh). The Fetch DRA Artifacts step now depends on the bump step, ensuring the version is updated before polling for artifacts at the new version. Made-with: Cursor --- .buildkite/job-version-bump.json.py | 38 ++++++------------ dev-tools/bump_version.sh | 61 +++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 27 deletions(-) create mode 100755 dev-tools/bump_version.sh diff --git a/.buildkite/job-version-bump.json.py b/.buildkite/job-version-bump.json.py index a979d30bec..e8ed4c6cff 100644 --- a/.buildkite/job-version-bump.json.py +++ b/.buildkite/job-version-bump.json.py @@ -20,24 +20,23 @@ def main(): pipeline = {} - # TODO: replace the block step with version bump logic pipeline_steps = [ { - "block": "Ready to fetch for DRA artifacts?", - "prompt": ( - "Unblock when your team is ready to proceed.\n\n" - "Trigger parameters:\n" - "- NEW_VERSION: ${NEW_VERSION}\n" - "- BRANCH: ${BRANCH}\n" - "- WORKFLOW: ${WORKFLOW}\n" - ), - "key": "block-get-dra-artifacts", - "blocked_state": "running", + "label": "Bump version to ${NEW_VERSION}", + "key": "bump-version", + "agents": { + "image": "docker.elastic.co/release-eng/wolfi-build-essential-release-eng:latest", + "cpu": "250m", + "memory": "512Mi", + }, + "command": [ + "dev-tools/bump_version.sh", + ], }, { "label": "Fetch DRA Artifacts", "key": "fetch-dra-artifacts", - "depends_on": "block-get-dra-artifacts", + "depends_on": "bump-version", "agents": { "image": "docker.elastic.co/release-eng/wolfi-build-essential-release-eng:latest", "cpu": "250m", @@ -88,21 +87,6 @@ def main(): "(build.state == 'passed' || build.state == 'failed')" ), }, - { - "slack": { - "channels": ["#machine-learn-build"], - "message": ( - "🚦 Pipeline waiting for approval 🚦\n" - "Repo: `${REPO}`\n\n" - "Ready to fetch DRA artifacts - please unblock when ready.\n" - "New version: `${NEW_VERSION}`\n" - "Branch: `${BRANCH}`\n" - "Workflow: `${WORKFLOW}`\n" - "${BUILDKITE_BUILD_URL}\n" - ), - }, - "if": 'build.state == "blocked"', - }, ] print(json.dumps(pipeline, indent=2)) diff --git a/dev-tools/bump_version.sh b/dev-tools/bump_version.sh new file mode 100755 index 0000000000..7c3cef9c05 --- /dev/null +++ b/dev-tools/bump_version.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +# or more contributor license agreements. Licensed under the Elastic License +# 2.0 and the following additional limitation. Functionality enabled by the +# files subject to the Elastic License 2.0 may only be used in production when +# invoked by an Elasticsearch process with a license key installed that permits +# use of machine learning features. You may not use this file except in +# compliance with the Elastic License 2.0 and the foregoing additional +# limitation. +# +# Automated version bump script for the release-eng pipeline. +# +# Updates elasticsearchVersion in gradle.properties to $NEW_VERSION, +# commits, and pushes directly to the target branch. Designed to be +# called from a Buildkite step with NEW_VERSION and BRANCH set. +# +# Follows the same pattern as the Elasticsearch repo's automated +# Lucene snapshot updates (.buildkite/scripts/lucene-snapshot/). + +set -euo pipefail + +: "${NEW_VERSION:?NEW_VERSION must be set}" +: "${BRANCH:?BRANCH must be set}" + +GRADLE_PROPS="gradle.properties" + +# Ensure we're on the correct branch and up to date +git checkout "$BRANCH" +git pull --ff-only origin "$BRANCH" + +CURRENT_VERSION=$(grep '^elasticsearchVersion=' "$GRADLE_PROPS" | cut -d= -f2) +if [ "$CURRENT_VERSION" = "$NEW_VERSION" ]; then + echo "Version is already $NEW_VERSION — nothing to do" + exit 0 +fi + +echo "Bumping version: $CURRENT_VERSION → $NEW_VERSION" +sed -i "s/^elasticsearchVersion=.*/elasticsearchVersion=${NEW_VERSION}/" "$GRADLE_PROPS" + +# Verify the substitution worked +if ! grep -q "^elasticsearchVersion=${NEW_VERSION}$" "$GRADLE_PROPS"; then + echo "ERROR: version update verification failed" + cat "$GRADLE_PROPS" + exit 1 +fi + +# Check there's actually a diff (guards against no-op) +if git diff-index --quiet HEAD --; then + echo "No changes to commit (file unchanged after sed)" + exit 0 +fi + +git config --global user.name elasticsearchmachine +git config --global user.email 'infra-root+elasticsearchmachine@elastic.co' + +git add "$GRADLE_PROPS" +git commit -m "[ML] Bump version to ${NEW_VERSION}" +git push origin "$BRANCH" + +echo "Version bumped to ${NEW_VERSION} on branch ${BRANCH}" From 79904fc20f3c498160db295903d5e96db5fdcf1b Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Wed, 8 Apr 2026 15:48:49 +1200 Subject: [PATCH 2/2] [ML] Add DRY_RUN mode to version bump script Adds a DRY_RUN=true option that performs all steps (checkout, sed, commit) but skips the final git push. Useful for testing the pipeline and for local verification. Also makes sed portable across macOS/Linux and uses local git config instead of --global. Made-with: Cursor --- dev-tools/bump_version.sh | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/dev-tools/bump_version.sh b/dev-tools/bump_version.sh index 7c3cef9c05..665a0805a3 100755 --- a/dev-tools/bump_version.sh +++ b/dev-tools/bump_version.sh @@ -15,6 +15,8 @@ # commits, and pushes directly to the target branch. Designed to be # called from a Buildkite step with NEW_VERSION and BRANCH set. # +# Set DRY_RUN=true to perform all steps except the final git push. +# # Follows the same pattern as the Elasticsearch repo's automated # Lucene snapshot updates (.buildkite/scripts/lucene-snapshot/). @@ -22,9 +24,14 @@ set -euo pipefail : "${NEW_VERSION:?NEW_VERSION must be set}" : "${BRANCH:?BRANCH must be set}" +DRY_RUN="${DRY_RUN:-false}" GRADLE_PROPS="gradle.properties" +if [ "$DRY_RUN" = "true" ]; then + echo "=== DRY RUN MODE — will not push ===" +fi + # Ensure we're on the correct branch and up to date git checkout "$BRANCH" git pull --ff-only origin "$BRANCH" @@ -36,12 +43,17 @@ if [ "$CURRENT_VERSION" = "$NEW_VERSION" ]; then fi echo "Bumping version: $CURRENT_VERSION → $NEW_VERSION" -sed -i "s/^elasticsearchVersion=.*/elasticsearchVersion=${NEW_VERSION}/" "$GRADLE_PROPS" +# macOS sed requires -i '' while GNU sed requires -i without an argument +if sed --version >/dev/null 2>&1; then + sed -i "s/^elasticsearchVersion=.*/elasticsearchVersion=${NEW_VERSION}/" "$GRADLE_PROPS" +else + sed -i '' "s/^elasticsearchVersion=.*/elasticsearchVersion=${NEW_VERSION}/" "$GRADLE_PROPS" +fi # Verify the substitution worked if ! grep -q "^elasticsearchVersion=${NEW_VERSION}$" "$GRADLE_PROPS"; then echo "ERROR: version update verification failed" - cat "$GRADLE_PROPS" + grep 'elasticsearchVersion' "$GRADLE_PROPS" exit 1 fi @@ -51,11 +63,23 @@ if git diff-index --quiet HEAD --; then exit 0 fi -git config --global user.name elasticsearchmachine -git config --global user.email 'infra-root+elasticsearchmachine@elastic.co' +git config user.name elasticsearchmachine +git config user.email 'infra-root+elasticsearchmachine@elastic.co' git add "$GRADLE_PROPS" git commit -m "[ML] Bump version to ${NEW_VERSION}" -git push origin "$BRANCH" -echo "Version bumped to ${NEW_VERSION} on branch ${BRANCH}" +if [ "$DRY_RUN" = "true" ]; then + echo "" + echo "=== DRY RUN: commit created but NOT pushed ===" + echo "Branch: $BRANCH" + echo "Version: $CURRENT_VERSION → $NEW_VERSION" + echo "Commit: $(git log -1 --format='%h %s')" + echo "Author: $(git log -1 --format='%an <%ae>')" + echo "" + echo "To inspect: git log -1 -p" + echo "To undo: git reset --soft HEAD~1 && git restore --staged $GRADLE_PROPS && git checkout -- $GRADLE_PROPS" +else + git push origin "$BRANCH" + echo "Version bumped to ${NEW_VERSION} on branch ${BRANCH}" +fi