Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 11 additions & 27 deletions .buildkite/job-version-bump.json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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))
Expand Down
85 changes: 85 additions & 0 deletions dev-tools/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/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.
#
# 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/).

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"

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"
# 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"
grep 'elasticsearchVersion' "$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 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}"

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