name: Multiarch build on: push: branches: - main pull_request: branches: - main release: types: - created env: IMAGE_NAME: zerotier jobs: build: name: Build images runs-on: ubuntu-latest strategy: fail-fast: false matrix: platform: [ {name: "linux/amd64", tag: "amd64"}, {name: "linux/386", tag: "i386"}, {name: "linux/arm64/v8", tag: "arm64v8"}, {name: "linux/arm/v7", tag: "arm32v7"}, {name: "linux/arm/v6", tag: "arm32v6"}, {name: "linux/riscv64", tag: "riscv64"} ] steps: - name: Checkout zerotier-docker uses: actions/checkout@v2 - name: Install qemu dependency run: | sudo apt-get update sudo apt-get install -y qemu-user-static - name: Build Image uses: redhat-actions/buildah-build@v2 with: image: ${{ env.IMAGE_NAME }} tags: ${{ matrix.platform.tag }} platform: ${{ matrix.platform.name }} build-args: | ALPINE_IMAGE=docker.io/alpine dockerfiles: | ./Dockerfile - name: Check images created run: buildah images | grep '${{ env.IMAGE_NAME }}' - name: Check image metadata run: | set -x buildah inspect ${{ env.IMAGE_NAME }}:${{ matrix.platform.tag }} | jq ".OCIv1.architecture" buildah inspect ${{ env.IMAGE_NAME }}:${{ matrix.platform.tag }} | jq ".Docker.architecture" - name: Export image run: podman save -o /tmp/image.tar ${{ env.IMAGE_NAME }}:${{ matrix.platform.tag }} - name: Upload artifact uses: actions/upload-artifact@v2 with: name: image-${{ matrix.platform.tag }} path: /tmp/image.tar push: name: Publish images runs-on: ubuntu-latest needs: build environment: production steps: - name: Download artifacts uses: actions/download-artifact@v2 - name: Import images run: | podman load -i ./image-amd64/image.tar podman load -i ./image-i386/image.tar podman load -i ./image-arm64v8/image.tar podman load -i ./image-arm32v7/image.tar podman load -i ./image-arm32v6/image.tar podman load -i ./image-riscv64/image.tar - name: Create multi-arch manifest run: | buildah manifest create ${{ env.IMAGE_NAME }}:latest buildah manifest add --arch amd64 ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:amd64 buildah manifest add --arch 386 ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:i386 buildah manifest add --arch arm64 --variant v8 ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:arm64v8 buildah manifest add --arch arm --variant v7 ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:arm32v7 buildah manifest add --arch arm --variant v6 ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:arm32v6 buildah manifest add --arch riscv64 ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:riscv64 - name: Push unstable images if: ${{ github.event_name == 'push' }} run: | buildah manifest push --all --format v2s2 --creds zyclonite:${{ secrets.REGISTRY_PASSWORD }} ${{ env.IMAGE_NAME }}:latest docker://docker.io/zyclonite/${{ env.IMAGE_NAME }}:main buildah manifest push --all --creds zyclonite:${{ secrets.QUAY_PASSWORD }} ${{ env.IMAGE_NAME }}:latest docker://quay.io/zyclonite/${{ env.IMAGE_NAME }}:main buildah manifest push --all --creds zyclonite:${{ secrets.GITHUB_TOKEN }} ${{ env.IMAGE_NAME }}:latest docker://ghcr.io/zyclonite/${{ env.IMAGE_NAME }}:main - name: Push stable images if: ${{ github.event_name == 'release' }} run: | buildah manifest push --all --format v2s2 --creds zyclonite:${{ secrets.REGISTRY_PASSWORD }} ${{ env.IMAGE_NAME }}:latest docker://docker.io/zyclonite/${{ env.IMAGE_NAME }}:latest buildah manifest push --all --format v2s2 --creds zyclonite:${{ secrets.REGISTRY_PASSWORD }} ${{ env.IMAGE_NAME }}:latest docker://docker.io/zyclonite/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }} buildah manifest push --all --creds zyclonite:${{ secrets.QUAY_PASSWORD }} ${{ env.IMAGE_NAME }}:latest docker://quay.io/zyclonite/${{ env.IMAGE_NAME }}:latest buildah manifest push --all --creds zyclonite:${{ secrets.QUAY_PASSWORD }} ${{ env.IMAGE_NAME }}:latest docker://quay.io/zyclonite/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }} buildah manifest push --all --creds zyclonite:${{ secrets.GITHUB_TOKEN }} ${{ env.IMAGE_NAME }}:latest docker://ghcr.io/zyclonite/${{ env.IMAGE_NAME }}:latest buildah manifest push --all --creds zyclonite:${{ secrets.GITHUB_TOKEN }} ${{ env.IMAGE_NAME }}:latest docker://ghcr.io/zyclonite/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }} bridge: uses: ./.github/workflows/bridge.yml needs: push with: tag: ${{ github.event.release.tag_name }} event: ${{ github.event_name }} secrets: REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}