From b668c92730a4afc237752d86b7aefe832652489f Mon Sep 17 00:00:00 2001 From: driazati Date: Wed, 22 Jun 2022 09:58:45 -0700 Subject: [PATCH] [ci][docker] Tag tlcpackstaging images to tlcpack See #11768, this PR changes the deploy workflow so that after a successful build with fallback images (see #11775), they get moved over to tlcpack automatically --- Jenkinsfile | 113 ++++++++++++++++++++++++++++++++++++++- jenkins/Deploy.groovy.j2 | 22 ++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d7d261ec99674..81e636856396f 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,7 +45,7 @@ // 'python3 jenkins/generate.py' // Note: This timestamp is here to ensure that updates to the Jenkinsfile are // always rebased on main before merging: -// Generated at 2022-06-20T19:48:32.482249 +// Generated at 2022-06-22T10:12:28.978722 import org.jenkinsci.plugins.pipeline.modeldefinition.Utils // NOTE: these lines are scanned by docker/dev_common.sh. Please update the regex as needed. --> @@ -3377,6 +3377,117 @@ def deploy() { } } } + if (env.BRANCH_NAME == 'main' && env.RETAG_STAGING_IMAGES == 'yes') { + withCredentials([string( + credentialsId: 'dockerhub-tlcpack-key', + variable: 'TLCPACK_TOKEN', + )]) { + if (ci_arm.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_arm.split(":")[1] + sh( + script: """ + set -eux + CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json" + MANIFEST=\$(curl -H "Accept: \${CONTENT_TYPE}" "https://hub.docker.com/v2/tlcpackstaging/ci_arm/manifests/${tag}") + curl -X PUT -H "Authorization: Bearer \${TLCPACK_TOKEN}" -H "Content-Type: \${CONTENT_TYPE}" -d "\${MANIFEST}" "https://hub.docker.com/v2/tlcpack/ci-arm/manifests/${tag}" + """, + label: 'Tag tlcpackstaging image to tlcpack', + ) + } + if (ci_cpu.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_cpu.split(":")[1] + sh( + script: """ + set -eux + CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json" + MANIFEST=\$(curl -H "Accept: \${CONTENT_TYPE}" "https://hub.docker.com/v2/tlcpackstaging/ci_cpu/manifests/${tag}") + curl -X PUT -H "Authorization: Bearer \${TLCPACK_TOKEN}" -H "Content-Type: \${CONTENT_TYPE}" -d "\${MANIFEST}" "https://hub.docker.com/v2/tlcpack/ci-cpu/manifests/${tag}" + """, + label: 'Tag tlcpackstaging image to tlcpack', + ) + } + if (ci_gpu.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_gpu.split(":")[1] + sh( + script: """ + set -eux + CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json" + MANIFEST=\$(curl -H "Accept: \${CONTENT_TYPE}" "https://hub.docker.com/v2/tlcpackstaging/ci_gpu/manifests/${tag}") + curl -X PUT -H "Authorization: Bearer \${TLCPACK_TOKEN}" -H "Content-Type: \${CONTENT_TYPE}" -d "\${MANIFEST}" "https://hub.docker.com/v2/tlcpack/ci-gpu/manifests/${tag}" + """, + label: 'Tag tlcpackstaging image to tlcpack', + ) + } + if (ci_hexagon.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_hexagon.split(":")[1] + sh( + script: """ + set -eux + CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json" + MANIFEST=\$(curl -H "Accept: \${CONTENT_TYPE}" "https://hub.docker.com/v2/tlcpackstaging/ci_hexagon/manifests/${tag}") + curl -X PUT -H "Authorization: Bearer \${TLCPACK_TOKEN}" -H "Content-Type: \${CONTENT_TYPE}" -d "\${MANIFEST}" "https://hub.docker.com/v2/tlcpack/ci-hexagon/manifests/${tag}" + """, + label: 'Tag tlcpackstaging image to tlcpack', + ) + } + if (ci_i386.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_i386.split(":")[1] + sh( + script: """ + set -eux + CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json" + MANIFEST=\$(curl -H "Accept: \${CONTENT_TYPE}" "https://hub.docker.com/v2/tlcpackstaging/ci_i386/manifests/${tag}") + curl -X PUT -H "Authorization: Bearer \${TLCPACK_TOKEN}" -H "Content-Type: \${CONTENT_TYPE}" -d "\${MANIFEST}" "https://hub.docker.com/v2/tlcpack/ci-i386/manifests/${tag}" + """, + label: 'Tag tlcpackstaging image to tlcpack', + ) + } + if (ci_lint.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_lint.split(":")[1] + sh( + script: """ + set -eux + CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json" + MANIFEST=\$(curl -H "Accept: \${CONTENT_TYPE}" "https://hub.docker.com/v2/tlcpackstaging/ci_lint/manifests/${tag}") + curl -X PUT -H "Authorization: Bearer \${TLCPACK_TOKEN}" -H "Content-Type: \${CONTENT_TYPE}" -d "\${MANIFEST}" "https://hub.docker.com/v2/tlcpack/ci-lint/manifests/${tag}" + """, + label: 'Tag tlcpackstaging image to tlcpack', + ) + } + if (ci_qemu.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_qemu.split(":")[1] + sh( + script: """ + set -eux + CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json" + MANIFEST=\$(curl -H "Accept: \${CONTENT_TYPE}" "https://hub.docker.com/v2/tlcpackstaging/ci_qemu/manifests/${tag}") + curl -X PUT -H "Authorization: Bearer \${TLCPACK_TOKEN}" -H "Content-Type: \${CONTENT_TYPE}" -d "\${MANIFEST}" "https://hub.docker.com/v2/tlcpack/ci-qemu/manifests/${tag}" + """, + label: 'Tag tlcpackstaging image to tlcpack', + ) + } + if (ci_wasm.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = ci_wasm.split(":")[1] + sh( + script: """ + set -eux + CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json" + MANIFEST=\$(curl -H "Accept: \${CONTENT_TYPE}" "https://hub.docker.com/v2/tlcpackstaging/ci_wasm/manifests/${tag}") + curl -X PUT -H "Authorization: Bearer \${TLCPACK_TOKEN}" -H "Content-Type: \${CONTENT_TYPE}" -d "\${MANIFEST}" "https://hub.docker.com/v2/tlcpack/ci-wasm/manifests/${tag}" + """, + label: 'Tag tlcpackstaging image to tlcpack', + ) + } + } + } if (env.BRANCH_NAME == 'main' && env.DEPLOY_DOCKER_IMAGES == 'yes' && rebuild_docker_images && upstream_revision != null) { node('CPU') { ws("workspace/exec_${env.EXECUTOR_NUMBER}/tvm/deploy-docker") { diff --git a/jenkins/Deploy.groovy.j2 b/jenkins/Deploy.groovy.j2 index 0249aaffc5123..434c40abe2fc3 100644 --- a/jenkins/Deploy.groovy.j2 +++ b/jenkins/Deploy.groovy.j2 @@ -86,6 +86,28 @@ def deploy() { } } } + if (env.BRANCH_NAME == 'main' && env.RETAG_STAGING_IMAGES == 'yes') { + withCredentials([string( + credentialsId: 'dockerhub-tlcpack-key', + variable: 'TLCPACK_TOKEN', + )]) { + {% for image in images %} + if ({{ image.name }}.contains("tlcpackstaging")) { + // Push image to tlcpack + def tag = {{ image.name }}.split(":")[1] + sh( + script: """ + set -eux + CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json" + MANIFEST=\$(curl -H "Accept: \${CONTENT_TYPE}" "https://hub.docker.com/v2/tlcpackstaging/{{ image.name }}/manifests/${tag}") + curl -X PUT -H "Authorization: Bearer \${TLCPACK_TOKEN}" -H "Content-Type: \${CONTENT_TYPE}" -d "\${MANIFEST}" "https://hub.docker.com/v2/tlcpack/{{ image.name.replace("_", "-") }}/manifests/${tag}" + """, + label: 'Tag tlcpackstaging image to tlcpack', + ) + } + {% endfor %} + } + } if (env.BRANCH_NAME == 'main' && env.DEPLOY_DOCKER_IMAGES == 'yes' && rebuild_docker_images && upstream_revision != null) { node('CPU') { ws({{ m.per_exec_ws('tvm/deploy-docker') }}) {