Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix: guard v3 Docker tag builds to the maintenance branch (#17035)

Valery Meleshkin1bbd84c53a2d
diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml
index 0710bcdc47..0144c25c6c 100644
--- a/.github/workflows/pipeline.yml
+++ b/.github/workflows/pipeline.yml
@@ -40,6 +40,24 @@ env:
CI_CACHE_ALLOWED: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
jobs:
+ validate-v3-release-tag:
+ if: ${{ github.event_name == 'push' && github.ref_type == 'tag' && (github.ref_name == 'v3' || startsWith(github.ref_name, 'v3.')) }}
+ runs-on: blacksmith-4vcpu-ubuntu-2404
+ timeout-minutes: 15
+ permissions:
+ contents: read
+ steps:
+ - name: Checkout full release history
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ fetch-depth: 0
+ persist-credentials: false
+ - name: Validate maintenance release tag branch
+ env:
+ RELEASE_COMMIT: ${{ github.sha }}
+ RELEASE_TAG: ${{ github.ref_name }}
+ run: bash "scripts/validate-release-tag-branch.sh" "${RELEASE_TAG}" "${RELEASE_COMMIT}" "origin/v3"
+
# Skips runs whose git tree was already tested in a prior successful run of
# this workflow (replaces fkirc/skip-duplicate-actions). This fires almost
# exclusively on pushes to main, whose tree the merge queue just tested, so
@@ -1233,6 +1251,7 @@ jobs:
e2e-tests,
test-docker-build,
e2e-server-tests,
+ validate-v3-release-tag,
]
if: always()
permissions:
diff --git a/scripts/validate-release-tag-branch.sh b/scripts/validate-release-tag-branch.sh
new file mode 100755
index 0000000000..677d470f3c
--- /dev/null
+++ b/scripts/validate-release-tag-branch.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+release_tag="${1:?Usage: validate-release-tag-branch.sh <tag> <release-ref> <maintenance-branch-ref>}"
+release_ref="${2:?Usage: validate-release-tag-branch.sh <tag> <release-ref> <maintenance-branch-ref>}"
+maintenance_branch_ref="${3:?Usage: validate-release-tag-branch.sh <tag> <release-ref> <maintenance-branch-ref>}"
+maintenance_line="${maintenance_branch_ref##*/}"
+
+if [[ "${release_tag}" != "${maintenance_line}" && "${release_tag}" != "${maintenance_line}."* ]]; then
+ echo "Tag ${release_tag} does not target maintenance line ${maintenance_line}; no branch check needed."
+ exit 0
+fi
+
+release_commit="$(git rev-parse --verify "${release_ref}^{commit}")"
+maintenance_branch_commit="$(git rev-parse --verify "${maintenance_branch_ref}^{commit}")"
+
+if git merge-base --is-ancestor "${release_commit}" "${maintenance_branch_commit}"; then
+ echo "Tag ${release_tag} points to a commit on ${maintenance_branch_ref}."
+ exit 0
+else
+ status="$?"
+fi
+
+if [[ "${status}" -ne 1 ]]; then
+ echo "::error::Unable to compare ${release_ref} with ${maintenance_branch_ref}."
+ exit "${status}"
+fi
+
+echo "::error::Tag ${release_tag} points to ${release_commit}, which is not on ${maintenance_branch_ref}. Refusing to publish maintenance-line Docker tags."
+exit 1