diff --git a/.github/workflows/official_release.yml b/.github/workflows/official_release.yml index ebf4a4281d..46974d6d22 100644 --- a/.github/workflows/official_release.yml +++ b/.github/workflows/official_release.yml @@ -36,17 +36,3 @@ jobs: env: TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: python binaries/upload.py --upload-pypi-packages - - name: Login to Docker - env: - DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} - run: docker login --username pytorchbot --password "$DOCKER_PASSWORD" - - name: Build & Upload pytorch/torchserve Docker images - run: | - cd docker - python build_upload_release.py - cd .. - - name: Build & Upload pytorch/torchserve-kfs Docker images - run: | - cd kubernetes/kserve - python build_upload_release.py - cd .. diff --git a/.github/workflows/official_release_docker.yml b/.github/workflows/official_release_docker.yml new file mode 100644 index 0000000000..7b788af728 --- /dev/null +++ b/.github/workflows/official_release_docker.yml @@ -0,0 +1,46 @@ +name: Make an official Release of Docker Images + +on: + workflow_dispatch: + inputs: + upload_docker: + description: 'Upload TorchServe Docker Images?' + required: true + default: 'no' + upload_kfs: + description: 'Upload TorchServe-kfs Docker Images?' + required: true + default: 'no' + +jobs: + official-release-docker: + runs-on: [self-hosted, ci-gpu] + steps: + - name: Clean up previous run + run: | + echo "Cleaning up previous run" + ls -la ./ + sudo rm -rf ./* || true + sudo rm -rf ./.??* || true + ls -la ./ + - name: Setup Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + architecture: x64 + - name: Checkout TorchServe + uses: actions/checkout@v3 + - name: Login to Docker + env: + DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} + run: docker login --username pytorchbot --password "$DOCKER_PASSWORD" + - name: Build & Upload pytorch/torchserve Docker images + if: github.event.inputs.upload_docker == 'yes' + run: | + cd docker + python build_upload_release.py --cleanup + - name: Build & Upload pytorch/torchserve-kfs Docker images + if: github.event.inputs.upload_kfs == 'yes' + run: | + cd kubernetes/kserve + python build_upload_release.py --cleanup diff --git a/docker/build_upload_release.py b/docker/build_upload_release.py index d0343ff0d1..8def7bb217 100644 --- a/docker/build_upload_release.py +++ b/docker/build_upload_release.py @@ -21,6 +21,11 @@ action="store_true", help="dry_run will print the commands that will be run without running them", ) + parser.add_argument( + "--cleanup", + action="store_true", + help="Delete all built docker images", + ) args = parser.parse_args() dry_run = args.dry_run organization = args.organization @@ -51,4 +56,8 @@ f"{organization}/torchserve:{check_ts_version()}-cpu", f"{organization}/torchserve:{check_ts_version()}-gpu", ]: - try_and_handle(f"docker push {image}") + os.system(f"docker push {image}") + + # Cleanup built images + if args.cleanup: + try_and_handle(f"docker system prune --all --volumes -f", dry_run) diff --git a/docker/docker_nightly.py b/docker/docker_nightly.py index 0522e3f734..63a6b66ffc 100644 --- a/docker/docker_nightly.py +++ b/docker/docker_nightly.py @@ -63,4 +63,4 @@ # Cleanup built images if args.cleanup: - try_and_handle(f"docker system prune --all --volumes", dry_run) + try_and_handle(f"docker system prune --all --volumes -f", dry_run) diff --git a/kubernetes/kserve/build_upload_release.py b/kubernetes/kserve/build_upload_release.py index cf0f360e5c..d10ae8533f 100644 --- a/kubernetes/kserve/build_upload_release.py +++ b/kubernetes/kserve/build_upload_release.py @@ -3,7 +3,7 @@ from argparse import ArgumentParser # To help discover local modules -REPO_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") +REPO_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../..") sys.path.append(REPO_ROOT) from ts_scripts.utils import check_ts_version, try_and_handle @@ -21,6 +21,11 @@ action="store_true", help="dry_run will print the commands that will be run without running them", ) + parser.add_argument( + "--cleanup", + action="store_true", + help="Delete all built docker images", + ) args = parser.parse_args() dry_run = args.dry_run organization = args.organization @@ -38,4 +43,8 @@ f"{organization}/torchserve-kfs:{check_ts_version()}", f"{organization}/torchserve-kfs:{check_ts_version()}-gpu", ]: - try_and_handle(f"docker push {image}", dry_run) + os.system(f"docker push {image}") + + # Cleanup built images + if args.cleanup: + try_and_handle(f"docker system prune --all --volumes -f", dry_run) diff --git a/kubernetes/kserve/docker_nightly.py b/kubernetes/kserve/docker_nightly.py index 1993e2c96b..209c0d976e 100644 --- a/kubernetes/kserve/docker_nightly.py +++ b/kubernetes/kserve/docker_nightly.py @@ -63,4 +63,4 @@ # Cleanup built images if args.cleanup: - try_and_handle(f"docker system prune --all --volumes", dry_run) + try_and_handle(f"docker system prune --all --volumes -f", dry_run)