[XPU] Allow the nightly XPU docker build to target a branch or tag (#39796)

This commit is contained in:
ashwini rathi
2026-09-17 13:23:09 +08:00
committed by GitHub
parent 1c4b130bf7
commit f6f69334ba
@@ -1,11 +1,16 @@
name: Release Docker Images Nightly (Intel XPU) name: Release Docker Images Nightly (Intel XPU)
on: on:
workflow_dispatch: workflow_dispatch:
inputs:
branch:
description: 'Branch or tag to build from, e.g. main, release/v0.5.20, v0.5.20.'
required: false
default: 'main'
schedule: schedule:
- cron: '0 12 * * *' - cron: '0 12 * * *'
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }} group: ${{ github.workflow }}-${{ inputs.branch || 'main' }}
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
@@ -17,11 +22,15 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
# Scheduled runs always build main; manual runs may pick a release branch or tag.
ref: ${{ inputs.branch || 'main' }}
path: sglang-nightly-build path: sglang-nightly-build
fetch-depth: 0 fetch-depth: 0
- name: Set date and commit hash - name: Set date and commit hash
id: image_meta id: image_meta
env:
SG_LANG_BRANCH: ${{ inputs.branch || 'main' }}
run: | run: |
cd sglang-nightly-build cd sglang-nightly-build
date_tag=$(date +%Y%m%d) date_tag=$(date +%Y%m%d)
@@ -30,10 +39,18 @@ jobs:
echo "::error::Could not resolve commit hash" echo "::error::Could not resolve commit hash"
exit 1 exit 1
fi fi
if [ "${SG_LANG_BRANCH}" = "main" ]; then
image_tag="nightly-dev-xpu-bmg-${date_tag}-${commit_hash}" image_tag="nightly-dev-xpu-bmg-${date_tag}-${commit_hash}"
else
# Slugify the ref so it is usable in a Docker tag (e.g. release/v0.5.20 -> release-v0.5.20).
branch_slug=$(echo "${SG_LANG_BRANCH}" | sed 's#[^a-zA-Z0-9._-]#-#g')
image_tag="nightly-dev-xpu-bmg-${branch_slug}-${date_tag}-${commit_hash}"
fi
echo "DATE=${date_tag}" >> $GITHUB_ENV echo "DATE=${date_tag}" >> $GITHUB_ENV
echo "commit_hash=${commit_hash}" >> $GITHUB_OUTPUT echo "commit_hash=${commit_hash}" >> $GITHUB_OUTPUT
echo "SG_LANG_BRANCH=${SG_LANG_BRANCH}" >> $GITHUB_ENV
echo "IMAGE_TAG=${image_tag}" >> $GITHUB_ENV echo "IMAGE_TAG=${image_tag}" >> $GITHUB_ENV
echo "Building ref ${SG_LANG_BRANCH} at ${commit_hash}"
echo "Image tag: ${image_tag}" echo "Image tag: ${image_tag}"
- name: Login to Docker Hub (Intel) - name: Login to Docker Hub (Intel)
@@ -44,14 +61,19 @@ jobs:
- name: Build intel/sglang-dev - name: Build intel/sglang-dev
run: | run: |
echo "Building intel/sglang-dev:${{ env.IMAGE_TAG }}" echo "Building intel/sglang-dev:${IMAGE_TAG} from ${SG_LANG_BRANCH}"
# Only main advances the rolling `latest` tag.
latest_tag=()
if [ "${SG_LANG_BRANCH}" = "main" ]; then
latest_tag=(-t "intel/sglang-dev:latest")
fi
docker build sglang-nightly-build \ docker build sglang-nightly-build \
-f sglang-nightly-build/docker/xpu.Dockerfile \ -f sglang-nightly-build/docker/xpu.Dockerfile \
--build-arg SG_LANG_REPO=https://github.com/sgl-project/sglang.git \ --build-arg SG_LANG_REPO=https://github.com/sgl-project/sglang.git \
--build-arg SG_LANG_BRANCH=main \ --build-arg SG_LANG_BRANCH="${SG_LANG_BRANCH}" \
--no-cache --progress=plain \ --no-cache --progress=plain \
-t "intel/sglang-dev:${{ env.IMAGE_TAG }}" \ -t "intel/sglang-dev:${IMAGE_TAG}" \
-t "intel/sglang-dev:latest" "${latest_tag[@]}"
- name: Push intel/sglang-dev - name: Push intel/sglang-dev
run: | run: |
@@ -63,5 +85,7 @@ jobs:
done done
return 1 return 1
} }
push_with_retry "intel/sglang-dev:${{ env.IMAGE_TAG }}" push_with_retry "intel/sglang-dev:${IMAGE_TAG}"
if [ "${SG_LANG_BRANCH}" = "main" ]; then
push_with_retry "intel/sglang-dev:latest" push_with_retry "intel/sglang-dev:latest"
fi