about summary refs log tree commit diff
path: root/.github/workflows/build-test-push-container.yaml
blob: 5d9e69e445de46c3ac35c6bbf9daa11c12bce358 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Build and test container image
on:
  push:
    branches:
      - stable
      - dev
    tags:
      - '*'
  pull_request:
    branch:
      - stable
      - dev

jobs:
  build-amd64:
    name: Build and test amd64
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Build amd64
        uses: docker/build-push-action@v3
        with:
          context: .
          platforms: linux/amd64
          load: true
          tags: aflplusplus/aflplusplus:test
          # cache-from: type=gha  # Ensure we always build a fresh image. We just use the cache for the subsequent push job.
          cache-to: type=gha,mode=max
      - name: Test linux/amd64 image
        run: docker run --rm --platform linux/amd64 aflplusplus/aflplusplus:test make tests
        continue-on-error: true
  build-arm64:
    name: Build and test arm64
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2
        with:
          platforms: arm64
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Build arm64
        uses: docker/build-push-action@v3
        with:
          context: .
          platforms: linux/arm64
          load: true
          tags: aflplusplus/aflplusplus:test
          # cache-from: type=gha  # Ensure we always build a fresh image. We just use the cache for the subsequent push job.
          cache-to: type=gha,mode=max
      - name: Test linux/arm64 image
        run: docker run --rm --platform linux/arm64 aflplusplus/aflplusplus:test make tests
        continue-on-error: true
  push:
    needs:
      - build-amd64
      - build-arm64
    if: ${{ github.event_name == 'push' }}
    name: Push image
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2
        with:
          platforms: arm64
      - 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_TOKEN }}
      - name: Publish ${{ github.ref_name }} for amd64 and arm64 to docker.io registry
        uses: docker/build-push-action@v3
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: aflplusplus/aflplusplus:${{ github.ref_name }}
          cache-from: type=gha
          # cache-to: type=gha,mode=max  # No need to add to cache as we'll never use this
        if: ${{ github.ref_name != 'stable' }}
      - name: Publish stable and latest to docker.io registry
        uses: docker/build-push-action@v3
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: aflplusplus/aflplusplus:${{ github.ref_name }},aflplusplus/aflplusplus:latest
          cache-from: type=gha
          # cache-to: type=gha,mode=max  # No need to add to cache as we'll never use this
        if: ${{ github.ref_name == 'stable' }}