5
5
tags : [ '[0-9]+.[0-9]+.[0-9]+' ]
6
6
7
7
env :
8
- REGISTRY : ghcr.io
8
+ GHCR_REPO : ghcr.io/${{ github.repository }}
9
9
10
10
jobs :
11
- package-amd64 :
12
- runs-on : buildjet-2vcpu-ubuntu-2204
11
+ build :
12
+ name : Build and Push
13
+ strategy :
14
+ fail-fast : false
15
+ matrix :
16
+ runner : [buildjet-2vcpu-ubuntu-2204-arm, buildjet-2vcpu-ubuntu-2204]
17
+ include :
18
+ - runner : buildjet-2vcpu-ubuntu-2204-arm
19
+ platform : linux/arm64
20
+ - runner : buildjet-2vcpu-ubuntu-2204
21
+ platform : linux/amd64
22
+ runs-on : ${{ matrix.runner }}
23
+
13
24
permissions :
14
- packages : write
15
25
contents : read
26
+ packages : write
27
+
16
28
steps :
17
- - name : Checkout
18
- uses : actions/checkout@v3
29
+ - name : Prepare
30
+ run : |
31
+ platform=${{ matrix.platform }}
32
+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
19
33
20
34
- name : Docker meta
21
35
id : meta
22
- uses : docker/metadata-action@v4
36
+ uses : docker/metadata-action@v5
23
37
with :
24
- images : ${{ env.REGISTRY }}/${{ github.repository }}
25
-
26
- - name : Set up Docker Buildx
27
- uses : docker/setup-buildx-action@v2
38
+ images : ${{ env.GHCR_REPO }}
28
39
29
- - name : Login to CR
30
- uses : docker/login-action@v2
40
+ - name : Login to GHCR
41
+ uses : docker/login-action@v3
31
42
with :
32
- registry : ${{ env.REGISTRY }}
43
+ registry : ghcr.io
33
44
username : ${{ github.repository_owner }}
34
45
password : ${{ secrets.GITHUB_TOKEN }}
35
46
36
- - name : Build docker image and push
37
- id : docker_build_amd64
38
- uses : docker/build-push-action@v4
39
- with :
40
- push : true
41
- platforms : linux/amd64
42
- labels : ${{ steps.meta.outputs.labels }}
43
- outputs : type=image,name=${{ env.REGISTRY }}/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true
44
-
45
- - name : Export digest
46
- run : |
47
- mkdir -p /tmp/digests
48
- digest="${{ steps.docker_build_amd64.outputs.digest }}"
49
- touch "/tmp/digests/${digest#sha256:}"
50
-
51
- - name : Upload digest
52
- uses : actions/upload-artifact@v3
53
- with :
54
- name : digests
55
- path : /tmp/digests/*
56
- if-no-files-found : error
57
- retention-days : 1
58
-
59
- package-arm64 :
60
- runs-on : buildjet-2vcpu-ubuntu-2204-arm
61
- permissions :
62
- packages : write
63
- contents : read
64
- steps :
65
- - name : Checkout
66
- uses : actions/checkout@v3
67
-
68
- - name : Docker meta
69
- id : meta
70
- uses : docker/metadata-action@v4
71
- with :
72
- images : ${{ env.REGISTRY }}/${{ github.repository }}
73
-
74
47
- name : Set up Docker Buildx
75
- uses : docker/setup-buildx-action@v2
48
+ uses : docker/setup-buildx-action@v3
76
49
77
- - name : Login to CR
78
- uses : docker/login-action@v2
79
- with :
80
- registry : ${{ env.REGISTRY }}
81
- username : ${{ github.repository_owner }}
82
- password : ${{ secrets.GITHUB_TOKEN }}
83
-
84
- - name : Build docker image and push
85
- id : docker_build_arm64
86
- uses : docker/build-push-action@v4
50
+ - name : Build and push by digest
51
+ id : build
52
+ uses : docker/build-push-action@v5
87
53
with :
54
+ platforms : ${{ matrix.platform }}
88
55
push : true
89
- platforms : linux/arm64
90
56
labels : ${{ steps.meta.outputs.labels }}
91
- outputs : type=image,name=${{ env.REGISTRY }}/${{ github.repository }} ,push-by-digest=true,name-canonical=true,push=true
57
+ outputs : type=image," name=${{ env.GHCR_REPO }}" ,push-by-digest=true,name-canonical=true,push=true
92
58
93
59
- name : Export digest
94
60
run : |
95
61
mkdir -p /tmp/digests
96
- digest="${{ steps.docker_build_arm64 .outputs.digest }}"
62
+ digest="${{ steps.build .outputs.digest }}"
97
63
touch "/tmp/digests/${digest#sha256:}"
98
64
99
65
- name : Upload digest
100
- uses : actions/upload-artifact@v3
66
+ uses : actions/upload-artifact@v4
101
67
with :
102
- name : digests
68
+ name : digests-${{ env.PLATFORM_PAIR }}
103
69
path : /tmp/digests/*
104
70
if-no-files-found : error
105
71
retention-days : 1
106
72
107
73
merge :
108
- runs-on : buildjet-2vcpu- ubuntu-2204
74
+ runs-on : ubuntu-latest
109
75
needs :
110
- - package-amd64
111
- - package-arm64
76
+ - build
112
77
permissions :
113
- packages : write
114
78
contents : read
79
+ packages : write
115
80
steps :
116
81
- name : Download digests
117
- uses : actions/download-artifact@v3
82
+ uses : actions/download-artifact@v4
118
83
with :
119
- name : digests
120
84
path : /tmp/digests
85
+ pattern : digests-*
86
+ merge-multiple : true
87
+
88
+ - name : Login to GHCR
89
+ uses : docker/login-action@v3
90
+ with :
91
+ registry : ghcr.io
92
+ username : ${{ github.repository_owner }}
93
+ password : ${{ secrets.GITHUB_TOKEN }}
121
94
122
95
- name : Set up Docker Buildx
123
- uses : docker/setup-buildx-action@v2
96
+ uses : docker/setup-buildx-action@v3
124
97
125
98
- name : Docker meta
126
99
id : meta
127
- uses : docker/metadata-action@v4
128
- with :
129
- images : ${{ env.REGISTRY }}/${{ github.repository }}
130
-
131
- - name : Login to CR
132
- uses : docker/login-action@v2
100
+ uses : docker/metadata-action@v5
133
101
with :
134
- registry : ${{ env.REGISTRY }}
135
- username : ${{ github.repository_owner }}
136
- password : ${{ secrets.GITHUB_TOKEN }}
102
+ images : ${{ env.GHCR_REPO }}
137
103
138
104
- name : Create manifest list and push
139
105
working-directory : /tmp/digests
140
106
run : |
141
107
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
142
- $(printf '${{ env.REGISTRY }}/${{ github.repository }}@sha256:%s ' *)
108
+ $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *)
143
109
144
110
- name : Inspect image
145
111
run : |
146
- docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ github.repository }}:${{ steps.meta.outputs.version }}
112
+ docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}
113
+
114
+ test :
115
+ runs-on : ubuntu-latest
116
+ steps :
117
+ - uses : actions/checkout@v4
118
+ - uses : actions/setup-go@v5
119
+ with :
120
+ go-version : ' stable'
121
+ - name : Gather dependencies
122
+ run : go mod download
123
+ - name : Run coverage
124
+ run : go test -race -tags=unit,integration -p 1 -coverprofile=coverage.txt -timeout 20m -covermode=atomic ./...
125
+ - name : Upload coverage to Codecov
126
+ uses : codecov/codecov-action@v4
127
+ with :
128
+ token : ${{ secrets.CODECOV_TOKEN }}
0 commit comments