2323 - ' **.md'
2424
2525env :
26- DOCKER_BUILDKIT : 1
26+ platforms : " linux/amd64,linux/arm64,linux/ppc64le,linux/s390x "
2727
2828concurrency :
2929 group : ${{ github.ref_name }}-ci
@@ -55,17 +55,21 @@ jobs:
5555 steps :
5656 - name : Checkout Repository
5757 uses : actions/checkout@v2
58+ - name : Cache Go build
59+ uses : actions/cache@v2
60+ with :
61+ path : |
62+ ~/.cache/go-build
63+ ~/go/pkg/mod
64+ key : ${{ runner.os }}-go-local-build-${{ hashFiles('**/go.sum') }}
65+ restore-keys : |
66+ ${{ runner.os }}-go-local-build-
5867 - name : Setup Golang Environment
5968 uses : actions/setup-go@v2
6069 with :
6170 go-version : ${{ needs.vars.outputs.go_version }}
6271 - name : Build Binary
6372 run : make build
64- - name : Cache Artifacts
65- uses : actions/cache@v2
66- with :
67- path : ${{ github.workspace }}/bin/manager
68- key : nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}
6973
7074 unit-tests :
7175 name : Unit Tests
@@ -78,27 +82,59 @@ jobs:
7882 uses : actions/setup-go@v2
7983 with :
8084 go-version : ${{ needs.vars.outputs.go_version }}
85+ - name : Cache Go tests
86+ uses : actions/cache@v2
87+ with :
88+ path : |
89+ ~/.cache/go-build
90+ ~/go/pkg/mod
91+ key : ${{ runner.os }}-go-tests-${{ hashFiles('**/go.sum') }}
92+ restore-keys : |
93+ ${{ runner.os }}-go-tests-
8194 - name : Run Tests
8295 run : make test
8396
8497 build :
8598 name : Build Image
8699 runs-on : ubuntu-20.04
87- needs : [binary, unit-tests]
100+ needs : [binary, vars, unit-tests]
88101 steps :
89102 - name : Checkout Repository
90103 uses : actions/checkout@v2
91- - name : Fetch Cached Artifacts
104+ with :
105+ fetch-depth : 0
106+ - name : Cache Go build
92107 uses : actions/cache@v2
93108 with :
94- path : ${{ github.workspace }}/bin/manager
95- key : nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }}
109+ path : |
110+ ~/.cache/go-build
111+ ~/go/pkg/mod
112+ key : ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
113+ restore-keys : |
114+ ${{ runner.os }}-go-build-
115+ - name : Setup Golang Environment
116+ uses : actions/setup-go@v2
117+ with :
118+ go-version : ${{ needs.vars.outputs.go_version }}
119+ - name : Build binaries
120+ uses : goreleaser/goreleaser-action@v2
121+ with :
122+ version : latest
123+ args : ${{ !startsWith(github.ref, 'refs/tags/') && 'build --snapshot' || 'release' }} ${{ github.event_name == 'pull_request' && '--single-target' || '' }} --rm-dist
124+ env :
125+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
126+ GOPATH : ${{ needs.check.outputs.go_path }}
96127 - name : DockerHub Login
97128 uses : docker/login-action@v1
98129 with :
99130 username : ${{ secrets.DOCKER_USERNAME }}
100131 password : ${{ secrets.DOCKER_PASSWORD }}
101132 if : github.event_name != 'pull_request'
133+ - name : Setup QEMU
134+ uses : docker/setup-qemu-action@v1
135+ with :
136+ platforms : arm64,ppc64le,s390x
137+ if : github.event_name != 'pull_request'
102138 - name : Docker Buildx
103139 uses : docker/setup-buildx-action@v1
104140 - name : Docker meta
@@ -120,8 +156,10 @@ jobs:
120156 context : ' .'
121157 cache-from : type=gha
122158 cache-to : type=gha,mode=max
159+ target : goreleaser
123160 tags : ${{ steps.meta.outputs.tags }}
124161 labels : ${{ steps.meta.outputs.labels }}
162+ platforms : ${{ github.event_name != 'pull_request' && env.platforms || '' }}
125163 load : ${{ github.event_name == 'pull_request' }}
126164 push : ${{ github.event_name != 'pull_request' }}
127165 pull : true
0 commit comments