From a40e43a80b747b3138ed5acfbca51411285ea536 Mon Sep 17 00:00:00 2001 From: whefter Date: Mon, 18 Sep 2023 17:32:21 +0200 Subject: [PATCH] feat: build for multiple target architectures --- .github/workflows/publish.yml | 32 +++++++++++++++++++++++++------- .github/workflows/scheduled.yml | 21 +++++++++++++++------ 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d464d23..6c01b3f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,13 +11,31 @@ jobs: name: build and publish Docker image steps: - name: Checkout code - uses: actions/checkout@v2 - - name: Build and push Docker images - uses: docker/build-push-action@v1 + uses: actions/checkout@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + whefter/cron + # generate Docker tags based on the following events/attributes + tags: | + type=semver,pattern={{raw}} + type=raw,value=latest + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: '386,amd64,arm64,arm' + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - repository: whefter/cron - tags: latest - tag_with_ref: true - push: ${{ startsWith(github.ref, 'refs/tags/') }} + - name: Build and push Docker images + uses: docker/build-push-action@v5 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + platforms: linux/amd64,linux/arm64/v8,linux/arm/v6,linux/arm/v7,linux/386 diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 6a8d0b6..6252b6e 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -10,21 +10,30 @@ jobs: name: build and publish Docker image steps: - name: checkout code to list tags - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: '386,amd64,arm64,arm' + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - name: set latest tag var id: latestTag run: echo ::set-output name=tag::$(git tag -l 'v*' --sort=taggerdate | tail -n 1) - name: checkout latest tag - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ steps.latestTag.outputs.tag }} - - name: build and push docker images - uses: docker/build-push-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - repository: whefter/cron - tags: latest,${{ steps.latestTag.outputs.tag }} + - name: build and push docker images + uses: docker/build-push-action@v5 + with: push: true + tags: whefter/cron:latest,whefter/cron:${{ steps.latestTag.outputs.tag }} + platforms: linux/amd64,linux/arm64/v8,linux/arm/v6,linux/arm/v7,linux/386