1313 - main
1414
1515jobs :
16+ build-cache :
17+ strategy :
18+ matrix :
19+ arch :
20+ - amd64
21+ - arm64
22+ - ppc64le
23+ - s390x
24+ platform : [linux]
25+ runs-on : ubuntu-latest
26+ steps :
27+ - name : Check out code into the Go module directory
28+ uses : actions/checkout@v3
29+ with :
30+ fetch-depth : 0
31+
32+ - name : Install Go
33+ uses : actions/setup-go@v4
34+ with :
35+ go-version-file : " go.mod"
36+
37+ - name : Set up QEMU
38+ uses : docker/setup-qemu-action@v2
39+
40+ - name : Set up Docker Buildx
41+ uses : docker/setup-buildx-action@v3
42+
43+ # The Dockerfile expects that ansible-operator will be copied from the
44+ # build context. We stub it here and then don't cache it. When Goreleaser
45+ # runs, it should copy over the right file.
46+ - name : Create ansible-operator stub
47+ run : echo stubbed-in-ci >> ansible-operator
48+
49+ - name : Build
50+ uses : docker/build-push-action@v6
51+ with :
52+ context : .
53+ platforms : " ${{ matrix.platform }}/${{ matrix.arch }}"
54+ push : false
55+ tags : " cache:${{ matrix.platform }}-${{ matrix.arch }}"
56+ file : images/ansible-operator/Dockerfile
57+ cache-from : type=gha,scope=${{ matrix.arch }}
58+ cache-to : type=gha,mode=max,scope=${{ matrix.arch }}
59+ no-cache-filters : final # don't cache this because the stubbed ansible-operator bin was copied in.
60+
1661 goreleaser :
17- name : goreleaser
62+ needs : [build-cache]
1863 runs-on : ubuntu-latest
1964 steps :
2065 - name : Check out code into the Go module directory
3883 - name : Set up QEMU
3984 uses : docker/setup-qemu-action@v2
4085
86+ - name : Set up Docker Buildx
87+ id : setup-buildx
88+ uses : docker/setup-buildx-action@v3
89+
4190 - name : Set the release related variables
4291 run : |
4392 if [[ $GITHUB_REF == refs/tags/* ]]; then
@@ -56,7 +105,13 @@ jobs:
56105 echo IMAGE_TAG="$(git describe --tags --always)" >> $GITHUB_ENV
57106 fi
58107
108+ # This gives us ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL
109+ # for use in goreleaser
110+ - name : Expose GitHub Runtime
111+ uses : crazy-max/ghaction-github-runtime@v3
112+
59113 - name : Run goreleaser
60114 run : make release
61115 env :
62116 GITHUB_TOKEN : ${{ github.token }}
117+ BUILDX_BUILDER : ${{ steps.setup-buildx.outputs.name }}
0 commit comments