From ab547e40cc648befd955e0e98d7e091f5071f5be Mon Sep 17 00:00:00 2001 From: limengxuan <391013634@qq.com> Date: Sat, 25 Jan 2025 15:09:59 +0800 Subject: [PATCH] Fix release ci (#841) * update ci Signed-off-by: limengxuan <391013634@qq.com> --- .github/workflows/auto-release.yaml | 9 +- .../call-release-image-hamicore.yaml | 116 ++++++++++++++++++ .github/workflows/call-release-image.yaml | 16 --- 3 files changed, 124 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/call-release-image-hamicore.yaml diff --git a/.github/workflows/auto-release.yaml b/.github/workflows/auto-release.yaml index 4a9ca44e2..681ada45a 100644 --- a/.github/workflows/auto-release.yaml +++ b/.github/workflows/auto-release.yaml @@ -101,8 +101,15 @@ jobs: sha: '${{ github.sha }}' - release-image: + release-image-hamicore: needs: ensure-tag + uses: ./.github/workflows/call-release-image-hamicore.yaml + with: + ref: ${{ needs.ensure-tag.outputs.tag }} + secrets: inherit + + release-image: + needs: [ensure-tag,release-image-hamicore] uses: ./.github/workflows/call-release-image.yaml with: ref: ${{ needs.ensure-tag.outputs.tag }} diff --git a/.github/workflows/call-release-image-hamicore.yaml b/.github/workflows/call-release-image-hamicore.yaml new file mode 100644 index 000000000..30b3144df --- /dev/null +++ b/.github/workflows/call-release-image-hamicore.yaml @@ -0,0 +1,116 @@ +name: Call Release Image + +env: + REGISTRY: docker.io + IMAGE_REPO: ${{ secrets.IMAGE_REPO || 'projecthami/hami' }} + IMAGE_REPO_HAMICORE: ${{ secrets.IMAGE_REPO || 'projecthami/hamicore' }} + IMAGE_ROOT_PATH: docker + BUILD_PLATFORM: linux/arm64,linux/amd64 + REGISTER_USER: ${{ github.actor }} + REGISTER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + +on: + workflow_call: + inputs: + ref: + required: true + type: string + suffix: + required: false + type: string + tagoverride: + required: false + type: string +permissions: write-all + +jobs: + docker-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Free disk space + # https://github.com/actions/virtual-environments/issues/709 + run: | + echo "=========original CI disk space" + df -h + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + echo "=========after clean up, the left CI disk space" + df -h + - name: Getting Image Ref + id: ref + run: | + if ${{ inputs.ref != '' }} ; then + echo "call by workflow_call" + image_ref=${{ inputs.ref }} + image_suffix=${{ inputs.suffix }} + elif ${{ github.event_name == 'workflow_dispatch' }} ; then + echo "call by workflow_dispatch" + image_ref=${{ github.event.inputs.ref }} + image_suffix=${{ github.event.inputs.suffix }} + else + echo "unexpected event: ${{ github.event_name }}" + exit 1 + fi + echo "ref=${image_ref}" >> $GITHUB_ENV + [ -n "${image_suffix}" ] && echo "suffix=-${image_suffix}" >> $GITHUB_ENV + if ${{ inputs.tagoverride != '' }} ; then + echo "imagetag=${{ inputs.tagoverride }}" >> $GITHUB_ENV + else + # it is invalid if the ref is branch name "xx/xx/xx" + echo "imagetag=${image_ref##*/}" >> $GITHUB_ENV + fi + exit 0 + + + - name: Checkout code + uses: actions/checkout@v4 + with: + persist-credentials: false + ref: ${{ steps.ref.outputs.ref }} + + - name: Checkout submodule + uses: Mushus/checkout-submodule@v1.0.1 + with: + basePath: # optional, default is . + submodulePath: libvgpu + + - name: Lint Dockerfile + run: | + make lint_dockerfile + + - name: Docker Login + uses: docker/login-action@v3.3.0 + with: + username: ${{ secrets.DOCKERHUB_TOKEN }} + password: ${{ secrets.DOCKERHUB_PASSWD }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: image=moby/buildkit:master + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_REPO_HAMICORE }} + + - name: Build & Pushing hami-core image + uses: docker/build-push-action@v6.11.0 + with: + context: . + file: ${{ env.IMAGE_ROOT_PATH }}/Dockerfile.hamicore + labels: ${{ steps.meta.outputs.labels }} + platforms: ${{ env.BUILD_PLATFORM }} + build-args: | + VERSION=${{ env.ref }} + GOLANG_IMAGE=golang:1.22.5-bullseye + NVIDIA_IMAGE=nvidia/cuda:12.2.0-devel-ubuntu20.04 + DEST_DIR=/usr/local + tags: ${{ steps.meta.outputs.tags }} + push: true + github-token: ${{ env.REGISTER_PASSWORD }} diff --git a/.github/workflows/call-release-image.yaml b/.github/workflows/call-release-image.yaml index dedaab870..e89d1cb5a 100644 --- a/.github/workflows/call-release-image.yaml +++ b/.github/workflows/call-release-image.yaml @@ -115,22 +115,6 @@ jobs: # push: true # github-token: ${{ env.REGISTER_PASSWORD }} - - name: Build & Pushing hami-core image - uses: docker/build-push-action@v6.11.0 - with: - context: . - file: ${{ env.IMAGE_ROOT_PATH }}/Dockerfile.hamicore - labels: ${{ steps.meta.outputs.labels }} - platforms: ${{ env.BUILD_PLATFORM }} - build-args: | - VERSION=${{ env.ref }} - GOLANG_IMAGE=golang:1.22.5-bullseye - NVIDIA_IMAGE=nvidia/cuda:12.2.0-devel-ubuntu20.04 - DEST_DIR=/usr/local - tags: ${{ steps.meta.outputs.tags }} - push: true - github-token: ${{ env.REGISTER_PASSWORD }} - - name: Extract metadata (tags, labels) for Docker id: meta1 uses: docker/metadata-action@v5