|
| 1 | +# GitHub actions workflow which builds and publishes the docker images. |
| 2 | + |
| 3 | +name: Build and push docker images |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + tags: ["v*"] |
| 8 | + branches: [ main ] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + packages: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Set up QEMU |
| 20 | + id: qemu |
| 21 | + uses: docker/setup-qemu-action@v2 |
| 22 | + with: |
| 23 | + platforms: arm64 |
| 24 | + |
| 25 | + - name: Set up Docker Buildx |
| 26 | + id: buildx |
| 27 | + uses: docker/setup-buildx-action@v2 |
| 28 | + |
| 29 | + - name: Inspect builder |
| 30 | + run: docker buildx inspect |
| 31 | + |
| 32 | + - name: Log in to DockerHub |
| 33 | + uses: docker/login-action@v2 |
| 34 | + with: |
| 35 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 36 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Log in to GHCR |
| 39 | + uses: docker/login-action@v2 |
| 40 | + with: |
| 41 | + registry: ghcr.io |
| 42 | + username: ${{ github.repository_owner }} |
| 43 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + |
| 45 | + - name: Calculate docker image tag |
| 46 | + id: set-tag |
| 47 | + uses: docker/metadata-action@master |
| 48 | + with: |
| 49 | + images: | |
| 50 | + ghcr.io/${{ github.repository }} |
| 51 | + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} |
| 52 | + flavor: | |
| 53 | + latest=false |
| 54 | + tags: | |
| 55 | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} |
| 56 | + type=semver,pattern=v{{version}} |
| 57 | + type=semver,pattern=v{{major}}.{{minor}} |
| 58 | +
|
| 59 | + - name: Build and push all platforms |
| 60 | + uses: docker/build-push-action@v4 |
| 61 | + with: |
| 62 | + push: true |
| 63 | + labels: "gitsha1=${{ github.sha }}" |
| 64 | + tags: "${{ steps.set-tag.outputs.tags }}" |
| 65 | + platforms: linux/amd64,linux/arm64 |
| 66 | + |
| 67 | + # arm64 builds OOM without the git fetch setting. c.f. |
| 68 | + # https://github.com/rust-lang/cargo/issues/10583 |
| 69 | + build-args: | |
| 70 | + CARGO_NET_GIT_FETCH_WITH_CLI=true |
| 71 | + BUILD_PROFILE=release |
0 commit comments