Update onnxruntime-gpu requirement from <1.20.0 to <1.21.0 #127
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages | |
# | |
name: Docker image on ghcr.io | |
on: | |
push: | |
tags: | |
- 'v*' | |
pull_request: | |
branches: main | |
schedule: | |
- cron: '0 2 1 6 *' # At 02:00 on day-of-month 1 in June (once a year actually) | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
image: | |
- "ubuntu:24.04" # Base image for CPU variants | |
- "nvidia/cuda:12.6.2-base-ubuntu24.04" # Base image for GPU | |
variant: | |
- "cpu-headless" # CPU variant 1 | |
- "openvino-headless" # CPU variant 2 | |
- "gpu-headless" # GPU variant | |
python: [3.10.13] | |
# Exclude invalid combinations | |
exclude: | |
- image: "nvidia/cuda:12.6.2-base-ubuntu24.04" | |
variant: "cpu-headless" | |
- image: "nvidia/cuda:12.6.2-base-ubuntu24.04" | |
variant: "openvino-headless" | |
- image: "ubuntu:24.04" | |
variant: "gpu-headless" | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Sanitize docker tag | |
run: | | |
# Start with the base prefix | |
PREFIX_DOCKER_TAG="OnnxTR-${{ matrix.variant }}-py${{ matrix.python }}" | |
# Replace any commas with hyphens (if needed) | |
PREFIX_DOCKER_TAG=$(echo "$PREFIX_DOCKER_TAG" | sed 's/,/-/g') | |
# Determine suffix based on image | |
IMAGE="${{ matrix.image }}" | |
case "$IMAGE" in | |
"nvidia/cuda:"*) | |
SUFFIX=$(echo "$IMAGE" | sed -E 's|.*/cuda:([0-9]+\.[0-9]+\.[0-9]+)-base-(ubuntu[0-9]+\.[0-9]+)|-\2-cuda\1|') | |
;; | |
"ubuntu:"*) | |
SUFFIX=$(echo "$IMAGE" | sed -E 's|ubuntu:([0-9]+\.[0-9]+)|-ubuntu\1|') | |
;; | |
*) | |
SUFFIX="" | |
;; | |
esac | |
# Combine the prefix, suffix, and ensure ending hyphen | |
PREFIX_DOCKER_TAG="${PREFIX_DOCKER_TAG}${SUFFIX}-" | |
# Export to environment | |
echo "PREFIX_DOCKER_TAG=${PREFIX_DOCKER_TAG}" >> $GITHUB_ENV | |
# Debugging output | |
echo "Final Docker Tag: $PREFIX_DOCKER_TAG" | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ github.repository }} | |
tags: | | |
# used only on schedule event | |
type=schedule,pattern={{date 'YYYY-MM'}},prefix=${{ env.PREFIX_DOCKER_TAG }} | |
# used only if a tag following semver is published | |
type=semver,pattern={{raw}},prefix=${{ env.PREFIX_DOCKER_TAG }} | |
- name: Build Docker image | |
id: build | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
build-args: | | |
BASE_IMAGE=${{ matrix.image }} | |
SYSTEM=${{ matrix.variant }} | |
PYTHON_VERSION=${{ matrix.python }} | |
ONNXTR_REPO=${{ github.repository }} | |
ONNXTR_VERSION=${{ github.sha }} | |
push: false # push only if `import onnxtr` works | |
tags: ${{ steps.meta.outputs.tags }} | |
- name: Check if `import onnxtr` works | |
run: docker run ${{ steps.build.outputs.imageid }} python3 -c 'import onnxtr; print(onnxtr.__version__)' | |
- name: Push Docker image | |
if: ${{ (github.ref == 'refs/heads/main' && github.event_name != 'pull_request') || (startsWith(github.ref, 'refs/tags') && github.event_name == 'push') }} | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
build-args: | | |
BASE_IMAGE=${{ matrix.image }} | |
SYSTEM=${{ matrix.variant }} | |
PYTHON_VERSION=${{ matrix.python }} | |
ONNXTR_REPO=${{ github.repository }} | |
ONNXTR_VERSION=${{ github.sha }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} |