Skip to content

Xorbits CD for DockerHub #728

Xorbits CD for DockerHub

Xorbits CD for DockerHub #728

Workflow file for this run

name: Xorbits CD for DockerHub
on:
schedule:
- cron: '0 18 * * *'
push:
tags:
- '*'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10", "3.11", "3.12" ]
cuda-version: [ "none", "12.0", "12.5" ]
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push Docker image
shell: bash
if: ${{ github.repository == 'xorbitsai/xorbits' }}
env:
DOCKER_ORG: ${{ secrets.DOCKERHUB_USERNAME }}
PYTHON_VERSION: ${{ matrix.python-version }}
CUDA_VERSION: ${{ matrix.cuda-version }}
run: |
if [[ "$GITHUB_REF" =~ ^"refs/tags/" ]]; then
export GIT_TAG=$(echo "$GITHUB_REF" | sed -e "s/refs\/tags\///g")
else
export GIT_BRANCH=$(echo "$GITHUB_REF" | sed -e "s/refs\/heads\///g")
fi
if [[ -n "$GIT_TAG" ]]; then
BRANCHES="$GIT_TAG"
echo "Will handle tag $BRANCHES"
else
MAINBRANCH=$(git rev-parse --abbrev-ref HEAD)
BRANCHES=$(git branch -r --list 'origin/v*' | sed 's/ *origin\///g')
BRANCHES="$MAINBRANCH $BRANCHES"
echo "Will handle branches:"
for branch in $BRANCHES; do
echo " $branch"
done
fi
for branch in $BRANCHES; do
if [[ -n "$GIT_TAG" ]]; then
export IMAGE_TAG="$GIT_TAG"
else
git checkout $branch
export IMAGE_TAG="nightly-$branch"
fi
if [[ "$CUDA_VERSION" == "none" ]]; then
# Build CPU image
docker build -t "$DOCKER_ORG/xorbits:base-py${PYTHON_VERSION}" --progress=plain -f python/xorbits/deploy/docker/Dockerfile.cpu.base . --build-arg PYTHON_VERSION=$PYTHON_VERSION
docker push "$DOCKER_ORG/xorbits:base-py${PYTHON_VERSION}"
docker build -t "$DOCKER_ORG/xorbits:${IMAGE_TAG}-py${PYTHON_VERSION}" --progress=plain -f python/xorbits/deploy/docker/Dockerfile.cpu . --build-arg PYTHON_VERSION=$PYTHON_VERSION
docker push "$DOCKER_ORG/xorbits:${IMAGE_TAG}-py${PYTHON_VERSION}"
else
# Build GPU image
docker build -t "$DOCKER_ORG/xorbits:${IMAGE_TAG}-cuda${CUDA_VERSION}-py${PYTHON_VERSION}" --progress=plain -f python/xorbits/deploy/docker/Dockerfile.cuda . --build-arg PYTHON_VERSION=$PYTHON_VERSION --build-arg CUDA_VERSION=$CUDA_VERSION
docker push "$DOCKER_ORG/xorbits:${IMAGE_TAG}-cuda${CUDA_VERSION}-py${PYTHON_VERSION}"
fi
done
- name: Set default image
shell: bash
if: matrix.python-version == '3.11'
env:
DOCKER_ORG: ${{ secrets.DOCKERHUB_USERNAME }}
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
if [[ "$GITHUB_REF" =~ ^"refs/tags/" ]]; then
export GIT_TAG=$(echo "$GITHUB_REF" | sed -e "s/refs\/tags\///g")
docker tag "$DOCKER_ORG/xorbits:${GIT_TAG}-py${PYTHON_VERSION}" "$DOCKER_ORG/xorbits:${GIT_TAG}"
docker push "$DOCKER_ORG/xorbits:${GIT_TAG}"
fi