diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 162cce0..de30f6d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -18,6 +18,9 @@ on: permissions: contents: read id-token: write + +env: + GHCR_REPO: ghcr.io/tuna2134/sbv2-api jobs: linux: @@ -129,36 +132,50 @@ jobs: command: upload args: --non-interactive --skip-existing wheels-*/* - build-docker: - runs-on: ${{ matrix.platform }} - if: "startsWith(github.ref, 'refs/tags/')" - permissions: - contents: read - packages: write + build: + runs-on: ${{ matrix.machine.runner }} strategy: + fail-fast: false matrix: - tag: [cpu, cuda] - platform: [ubuntu-latest, ubuntu-24.04-arm] + machine: + - platform: linux/amd64 + runner: ubuntu-latest + - platform: linux/arm64 + runner: ubuntu-24.04-arm64 steps: - - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Login to GitHub Container Registry + - name: Prepare + run: | + platform=${{ matrix.machine.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.GHCR_REPO }} + + - name: Login to GHCR uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push image + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push by digest + id: build uses: docker/build-push-action@v6 with: - context: . - file: docker/${{ matrix.tag }}.Dockerfile + platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} - outputs: type=image,"name=ghcr.io/tuna2134/sbv2-api",push-by-digest=true,name-canonical=true,push=true - + outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true + - name: Export digest run: | mkdir -p ${{ runner.temp }}/digests @@ -176,7 +193,7 @@ jobs: merge: runs-on: ubuntu-latest needs: - - build-docker + - build steps: - name: Download digests uses: actions/download-artifact@v4 @@ -200,7 +217,7 @@ jobs: uses: docker/metadata-action@v5 with: images: | - ghcr.io/tuna2134/sbv2-api + ${{ env.GHCR_REPO }} tags: | type=ref,event=branch type=ref,event=pr @@ -211,8 +228,8 @@ jobs: working-directory: ${{ runner.temp }}/digests run: | docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf 'ghcr.io/tuna2134/sbv2-api@sha256:%s ' *) + $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) - name: Inspect image run: | - docker buildx imagetools inspect ghcr.io/tuna2134/sbv2-api:${{ steps.meta.outputs.version }} + docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}