Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1f5d211
ci: resolve the sglang ref and the CI image from release-lock.json
Rockdu Nov 10, 2026
41b60b5
ci: let release-branch-cut call pr-test.yml on an exact commit
Rockdu Nov 10, 2026
8b852cc
ci(release): add the version bump, image pick and lockfile scripts
Rockdu Nov 10, 2026
e51d60b
ci(release): add release-branch-cut workflow
Rockdu Nov 10, 2026
4e5dfec
ci(release): add release-tag workflow
Rockdu Nov 10, 2026
f8ef94a
ci(release): add release-docker workflow
Rockdu Nov 10, 2026
260d055
ci(release): add bot-cherry-pick workflow
Rockdu Nov 10, 2026
2f57043
docs: add the release runbook and the docker release rule
Rockdu Nov 10, 2026
c0ce61d
ci(release): check the two lock digests with plain asserts
Rockdu Nov 10, 2026
a3b7f7d
ci: name the workflow_call image input ci_image_tag as on dispatch
Rockdu Nov 10, 2026
bffa7d4
ci(release): spell out the abbreviated release variable names
Rockdu Nov 10, 2026
c1b17d5
ci(release): move the lock field comments above the literal
Rockdu Nov 10, 2026
e0241d3
ci: add the lockfile tag to resolve-ci-image's header comment
Rockdu Nov 10, 2026
ab0d2c6
docs: say which inputs a versioned image tag pins, not all of them
Rockdu Nov 10, 2026
5c5c557
ci(release): spell the sglang commit SGLANG_COMMIT, as the lock does
Rockdu Nov 10, 2026
019bc32
ci(release): trim the lockfile and image-guard comments
Rockdu Nov 10, 2026
19bc02e
ci(release): spell the cherry-pick image-layer path pattern once
Rockdu Nov 10, 2026
2fef824
ci: describe the lockfile fallback on record-e2e-standards' sglang input
Rockdu Nov 10, 2026
5d1b2c2
ci(release): fail on an unreadable lockfile instead of echoing empty …
Rockdu Nov 10, 2026
7ac6947
ci(release): accept only well-formed digests and SHAs from the image …
Rockdu Nov 10, 2026
f7d2e81
ci(release): let bump_version.py accept only the base version X.Y.Z
Rockdu Nov 10, 2026
fcfc523
docs: say record-e2e-standards gets only the sglang pin on a release …
Rockdu Nov 10, 2026
af38962
ci(release): retag the CI image only after every lock input resolved
Rockdu Nov 10, 2026
95bbe76
ci(release): put the pipefail comment on the step that has pipelines
Rockdu Nov 10, 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
35 changes: 35 additions & 0 deletions .github/scripts/release/bump_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Bump the miles_diffusion base version in setup.py.

Usage: python .github/scripts/release/bump_version.py 0.3.0

Ported from radixark/miles (.github/scripts/release/bump_miles_version.py).
"""

import re
import sys
from pathlib import Path

VERSION_RE = re.compile(r"^\d+\.\d+\.\d+$")


def main() -> int:
if len(sys.argv) != 2:
print(__doc__.strip(), file=sys.stderr)
return 1
new_version = sys.argv[1]
if not VERSION_RE.fullmatch(new_version):
# setup.py carries the base version only; rcN / .postN belong to the tag.
print(f"Invalid version {new_version!r}; expected the base version X.Y.Z", file=sys.stderr)
return 1

setup_py = Path(__file__).resolve().parents[3] / "setup.py"
content = setup_py.read_text()
new_content, n = re.subn(r'version="[^"]+"', f'version="{new_version}"', content)
assert n == 1, f"expected exactly one version= assignment in setup.py, found {n}"
setup_py.write_text(new_content)
print(f"setup.py: version -> {new_version}")
return 0


if __name__ == "__main__":
raise SystemExit(main())
72 changes: 72 additions & 0 deletions .github/scripts/release/pick_ci_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""Pick the dated CI image a release branch cut freezes, and prove it matches a build.

Usage: pick_ci_image.py <docker-build-run.json> <docker-hub-tags.json>

<docker-build-run.json> is the newest successful docker-build.yml run:
gh run list --workflow docker-build.yml --status success --limit 1 \
--json headSha,headBranch,createdAt,updatedAt
<docker-hub-tags.json> is the Docker Hub tag listing of radixark/miles_diffusion.

Prints `key=value` lines for the workflow: dev_image_tag, dev_image_digest,
image_build_sha. Fails when the newest dated tag was not pushed by that run
(it must be a main build, and the tag's push time must fall inside the run),
because the cut then cannot say which Dockerfile the frozen image represents.
"""

import json
import re
import sys
from datetime import datetime

DATED_TAG_RE = re.compile(r"dev-cu129-sglang-main-\d{8}")


def parse_time(value: str) -> datetime:
# Docker Hub carries fractional seconds, gh does not; fromisoformat takes both.
return datetime.fromisoformat(value.replace("Z", "+00:00"))


def main() -> int:
run_path, tags_path = sys.argv[1:]
runs = json.load(open(run_path))
tags = json.load(open(tags_path))["results"]

dated_tags = sorted((t for t in tags if DATED_TAG_RE.fullmatch(t["name"])), key=lambda t: t["name"])
if not dated_tags:
print(
"no dev-cu129-sglang-main-<YYYYMMDD> tag on Docker Hub; dispatch docker-build.yml first", file=sys.stderr
)
return 1
newest_tag = dated_tags[-1]

if not runs:
print("no successful docker-build.yml run found", file=sys.stderr)
return 1
run = runs[0]
if run["headBranch"] != "main":
print(f"newest successful docker-build.yml run is on {run['headBranch']!r}, not main", file=sys.stderr)
return 1
pushed_at = parse_time(newest_tag["last_updated"])
if not parse_time(run["createdAt"]) <= pushed_at <= parse_time(run["updatedAt"]):
print(
f"{newest_tag['name']} (pushed {newest_tag['last_updated']}) was not pushed by the newest successful "
f"docker-build.yml run ({run['createdAt']} .. {run['updatedAt']}); rebuild the image on main first",
file=sys.stderr,
)
return 1

# The workflow sources these lines: accept only the exact digest / SHA shapes.
if not re.fullmatch(r"sha256:[0-9a-f]{64}", newest_tag["digest"] or ""):
print(f"unexpected digest for {newest_tag['name']}: {newest_tag['digest']!r}", file=sys.stderr)
return 1
if not re.fullmatch(r"[0-9a-f]{40}", run["headSha"]):
print(f"unexpected headSha: {run['headSha']!r}", file=sys.stderr)
return 1
print(f"dev_image_tag={newest_tag['name']}")
print(f"dev_image_digest={newest_tag['digest']}")
print(f"image_build_sha={run['headSha']}")
return 0


if __name__ == "__main__":
raise SystemExit(main())
53 changes: 53 additions & 0 deletions .github/scripts/release/write_release_lock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Write release-lock.json for a release branch cut.

Ported from radixark/miles (.github/scripts/release/write_release_lock.py) with
miles_diffusion's inputs: no Megatron-LM, one CUDA 12.9 x86_64 image, and the
base image pinned by digest because `docker build --pull` re-resolves its tag.
"""

import argparse
import json


def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--release-branch", required=True)
parser.add_argument("--sglang-commit", required=True)
parser.add_argument("--ci-image-tag", required=True)
parser.add_argument("--ci-image-digest", required=True)
parser.add_argument("--sglang-image-tag", required=True)
parser.add_argument("--sglang-image-digest", required=True)
parser.add_argument("--fa3-wheels-repo", required=True)
parser.add_argument("--fa3-wheels-tag", required=True)
parser.add_argument("--fa3-wheels-fingerprint", required=True)
args = parser.parse_args()

assert len(args.sglang_commit) == 40, "failed to resolve the sglang commit"
assert args.ci_image_digest.startswith("sha256:"), "failed to resolve ci_image_digest"
assert args.sglang_image_digest.startswith("sha256:"), "failed to resolve sglang_image_digest"
assert args.fa3_wheels_fingerprint, "failed to fingerprint the FA3 wheels release"

# Restored inputs: release CI re-installs sglang at sglang_commit and runs
# inside ci_image_tag; release-docker.yml bakes sglang_commit and builds
# FROM sglang_image_tag@sglang_image_digest. ci_image_digest and the
# fa3_wheels_* fields are audit records: a rolling wheels release can have
# its assets replaced in place, so it cannot be pinned by name.
lock = {
"release_branch": args.release_branch,
"sglang_repo": "sgl-project/sglang",
"sglang_branch": "sglang-miles",
"sglang_commit": args.sglang_commit,
"ci_image_tag": args.ci_image_tag,
"ci_image_digest": args.ci_image_digest,
"sglang_image_tag": args.sglang_image_tag,
"sglang_image_digest": args.sglang_image_digest,
"fa3_wheels_repo": args.fa3_wheels_repo,
"fa3_wheels_tag": args.fa3_wheels_tag,
"fa3_wheels_fingerprint": args.fa3_wheels_fingerprint,
}
json.dump(lock, open("release-lock.json", "w"), indent=2)
return 0


if __name__ == "__main__":
raise SystemExit(main())
29 changes: 26 additions & 3 deletions .github/workflows/_run-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ on:
required: false
default: false
description: 'Upload tests/ci/fixtures/e2e_standards/ as a build artifact for the author to review and commit (record-e2e-standards.yml)'
ref:
type: string
required: false
default: ''
description: 'Exact commit to test (release CI). Empty: the PR merge ref, else github.sha.'

env:
# Unless you know the consequences, change this together with docker/Dockerfile's
Expand Down Expand Up @@ -80,7 +85,7 @@ jobs:
working-directory: ${{ github.workspace }}
env:
PYTHONPATH: ${{ github.workspace }}
GITHUB_COMMIT_NAME: ${{ github.sha }}_${{ github.event.pull_request.number || 'non-pr' }}
GITHUB_COMMIT_NAME: ${{ inputs.ref || github.sha }}_${{ github.event.pull_request.number || 'non-pr' }}
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
# Gated models (e.g. stabilityai/stable-diffusion-3.5-medium for the SD3
# e2e) need an HF token with repo access; unset for public-model tests.
Expand All @@ -90,7 +95,8 @@ jobs:
uses: actions/checkout@v4
with:
# Review-triggered callers otherwise check out the default branch.
ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_review') && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
# release CI: github.sha is the main tip the cut was dispatched on
ref: ${{ inputs.ref || ((github.event_name == 'pull_request' || github.event_name == 'pull_request_review') && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha) }}

- name: Cleanup Ray processes
shell: bash
Expand Down Expand Up @@ -142,6 +148,14 @@ jobs:
PR_SGLANG_REPO=$(echo "$PR_BODY" | grep -m1 -oP '^ci-sglang-repo:\s+\K\S+' || true)
[ -z "$SGLANG_REPO" ] && [ -n "$PR_SGLANG_REPO" ] && SGLANG_REPO="$PR_SGLANG_REPO"
fi
# release-lock.json (committed by release-branch-cut.yml) names the
# sglang commit a release branch was frozen with; its repo and
# commit apply as a pair.
if [ -z "$SGLANG_PR" ] && [ -f release-lock.json ]; then
SGLANG_PR=$(python3 -c "import json; print(json.load(open('release-lock.json'))['sglang_commit'])")
SGLANG_REPO=$(python3 -c "import json; print(json.load(open('release-lock.json'))['sglang_repo'])")
echo "release-lock.json present: sglang=${SGLANG_REPO}@${SGLANG_PR}"
fi
[ -z "$SGLANG_PR" ] && SGLANG_PR="$DEFAULT_SGLANG_REF"
[ -z "$SGLANG_REPO" ] && SGLANG_REPO="$DEFAULT_SGLANG_REPO"
resolve_fetch_ref() {
Expand Down Expand Up @@ -217,7 +231,8 @@ jobs:
- name: Checkout miles-diffusion
uses: actions/checkout@v4
with:
ref: ${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_review') && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha }}
# release CI: github.sha is the main tip the cut was dispatched on
ref: ${{ inputs.ref || ((github.event_name == 'pull_request' || github.event_name == 'pull_request_review') && format('refs/pull/{0}/merge', github.event.pull_request.number) || github.sha) }}

- name: Set up Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -251,6 +266,14 @@ jobs:
PR_SGLANG_REPO=$(echo "$PR_BODY" | grep -m1 -oP '^ci-sglang-repo:\s+\K\S+' || true)
[ -z "$SGLANG_REPO" ] && [ -n "$PR_SGLANG_REPO" ] && SGLANG_REPO="$PR_SGLANG_REPO"
fi
# release-lock.json (committed by release-branch-cut.yml) names the
# sglang commit a release branch was frozen with; its repo and
# commit apply as a pair.
if [ -z "$SGLANG_PR" ] && [ -f release-lock.json ]; then
SGLANG_PR=$(python3 -c "import json; print(json.load(open('release-lock.json'))['sglang_commit'])")
SGLANG_REPO=$(python3 -c "import json; print(json.load(open('release-lock.json'))['sglang_repo'])")
echo "release-lock.json present: sglang=${SGLANG_REPO}@${SGLANG_PR}"
fi
[ -z "$SGLANG_PR" ] && SGLANG_PR="$DEFAULT_SGLANG_REF"
[ -z "$SGLANG_REPO" ] && SGLANG_REPO="$DEFAULT_SGLANG_REPO"
resolve_fetch_ref() {
Expand Down
106 changes: 106 additions & 0 deletions .github/workflows/bot-cherry-pick.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Bot Cherry Pick to Release Branch

# Ported from radixark/miles (.github/workflows/bot-cherry-pick.yml);
# runbook: docs/developer/release.md.
#
# Picks a merged main PR (or a raw commit) onto a release branch. Re-dispatch
# release-branch-cut.yml on the branch afterwards to re-run the full CI.

on:
workflow_dispatch:
inputs:
pr_number:
description: 'Merged PR number to cherry-pick (preferred). Provide either pr_number OR commit_sha.'
required: false
type: string
commit_sha:
description: 'Commit SHA to cherry-pick (alternative to pr_number).'
required: false
type: string
target_branch:
description: 'Target release branch (e.g., release/v0.3.0)'
required: true
type: string

permissions:
contents: write

jobs:
cherry-pick:
if: github.repository == 'radixark/miles_diffusion'
runs-on: ubuntu-latest
steps:
- name: Validate inputs
env:
TARGET_BRANCH: ${{ github.event.inputs.target_branch }}
PR_NUMBER: ${{ github.event.inputs.pr_number }}
COMMIT_SHA: ${{ github.event.inputs.commit_sha }}
run: |
if [[ ! "$TARGET_BRANCH" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Target branch must match 'release/vX.Y.Z'"
exit 1
fi
if [[ -z "$PR_NUMBER" && -z "$COMMIT_SHA" ]] || [[ -n "$PR_NUMBER" && -n "$COMMIT_SHA" ]]; then
echo "::error::Provide exactly one of pr_number or commit_sha"
exit 1
fi

- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Cherry-pick and push
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_BRANCH: ${{ github.event.inputs.target_branch }}
PR_NUMBER: ${{ github.event.inputs.pr_number }}
COMMIT_SHA: ${{ github.event.inputs.commit_sha }}
run: |
git config user.name "miles-bot"
git config user.email "miles-bot@users.noreply.github.com"

if [ -n "$PR_NUMBER" ]; then
COMMIT_SHA=$(gh pr view "$PR_NUMBER" --json mergeCommit,state -q '.mergeCommit.oid')
if [ -z "$COMMIT_SHA" ] || [ "$COMMIT_SHA" = "null" ]; then
echo "::error::PR #$PR_NUMBER has no merge commit (not merged?)"
exit 1
fi
fi

# Refuse to pick anything that is not on main: fixes land on main first
# (review + CI), then get picked. Covers both input paths — a PR merged
# into a non-main base also fails this check.
if ! git merge-base --is-ancestor "$COMMIT_SHA" origin/main; then
echo "::error::Commit $COMMIT_SHA is not on main; only merged main commits can be cherry-picked"
exit 1
fi

# The frozen release-v*-ci image bakes the cut point's Dockerfile and
# requirements.txt, and the GPU suites never reinstall requirements.txt
# (only the CPU job does): a pick changing either would be tested in
# the old image while release-docker publishes an untested new one.
# Same paths as pr-test.yml's docker-paths filter.
IMAGE_LAYER_PATHS='^(docker/Dockerfile|requirements\.txt)$'
if git diff --name-only "${COMMIT_SHA}^1" "$COMMIT_SHA" | grep -qE "$IMAGE_LAYER_PATHS"; then
echo "::error::Commit $COMMIT_SHA touches image-layer files; the frozen CI image cannot represent it. Ship this as a new release (bump + release-branch-cut) instead of a cherry-pick."
git diff --name-only "${COMMIT_SHA}^1" "$COMMIT_SHA" | grep -E "$IMAGE_LAYER_PATHS"
exit 1
fi

if ! git ls-remote --exit-code --heads origin "$TARGET_BRANCH" > /dev/null 2>&1; then
echo "::error::Target branch '$TARGET_BRANCH' does not exist"
exit 1
fi
git checkout -b work "origin/$TARGET_BRANCH"

# -m 1 handles merge commits (squash merges are plain commits, unaffected).
if git rev-parse "$COMMIT_SHA^2" >/dev/null 2>&1; then
git cherry-pick -m 1 -x "$COMMIT_SHA"
else
git cherry-pick -x "$COMMIT_SHA"
fi

git push origin "work:$TARGET_BRANCH"
echo "Cherry-picked $COMMIT_SHA onto $TARGET_BRANCH"
echo "Re-run CI: gh workflow run release-branch-cut.yml -f branch_name=$TARGET_BRANCH" >> "$GITHUB_STEP_SUMMARY"
Loading
Loading