9
9
- ' v*'
10
10
pull_request :
11
11
12
+ env :
13
+ REGISTRY : ghcr.io
14
+ REGISTRY_IMAGE : ghcr.io/${{ github.repository }}
15
+
12
16
permissions :
13
17
contents : write
14
18
packages : write
@@ -19,54 +23,61 @@ jobs:
19
23
runs-on : ubuntu-latest
20
24
steps :
21
25
- name : Checkout
22
- uses : actions/checkout@v3
26
+ uses : actions/checkout@v4
23
27
with :
24
28
fetch-depth : 0
25
29
26
30
- name : Set up Go
27
- uses : actions/setup-go@v3
31
+ uses : actions/setup-go@v5
28
32
with :
29
- go-version : ' 1.21 '
33
+ go-version : ' 1.22.0 '
30
34
cache : true
31
35
32
36
- name : Test
33
- run : go test -v ./...
37
+ run : go run gotest.tools/gotestsum@latest --junitfile unit-tests.xml --format pkgname -- ./...
38
+
39
+ - name : Test Summary
40
+ uses : test-summary/action@v2
41
+ with :
42
+ paths : " unit-tests.xml"
43
+ if : always()
34
44
35
45
goreleaser :
36
46
name : Build and publish Go binaries
37
47
runs-on : ubuntu-latest
48
+ needs : [test]
38
49
steps :
39
50
- name : Checkout
40
- uses : actions/checkout@v3
51
+ uses : actions/checkout@v4
41
52
with :
42
53
fetch-depth : 0
43
54
44
55
- name : Set up Go
45
- uses : actions/setup-go@v3
56
+ uses : actions/setup-go@v5
46
57
with :
47
- go-version : ' 1.21 '
58
+ go-version : ' 1.22.0 '
48
59
cache : true
49
60
50
61
- name : Run GoReleaser build
51
- uses : goreleaser/goreleaser-action@v4
62
+ uses : goreleaser/goreleaser-action@v5
52
63
if : ${{ github.event_name == 'pull_request' }}
53
64
with :
54
65
distribution : goreleaser
55
66
version : latest
56
- args : release --snapshot
67
+ args : release --clean --skip=validate --skip=publish --parallelism 5 -- snapshot
57
68
58
69
- name : Run GoReleaser build and publish tags
59
- uses : goreleaser/goreleaser-action@v4
70
+ uses : goreleaser/goreleaser-action@v5
60
71
if : startsWith(github.ref, 'refs/tags/')
61
72
with :
62
73
distribution : goreleaser
63
74
version : latest
64
- args : release --rm-dist
75
+ args : release --clean
65
76
env :
66
77
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
67
78
68
79
- name : Upload assets
69
- uses : actions/upload-artifact@v3
80
+ uses : actions/upload-artifact@v4
70
81
with :
71
82
name : omegabrr
72
83
path : |
@@ -77,45 +88,128 @@ jobs:
77
88
docker :
78
89
name : Build and publish Docker images
79
90
runs-on : ubuntu-latest
91
+ needs : [test]
92
+ strategy :
93
+ fail-fast : true
94
+ matrix :
95
+ platform :
96
+ - linux/386
97
+ - linux/amd64
98
+ - linux/amd64/v2
99
+ - linux/amd64/v3
100
+ - linux/arm/v6
101
+ - linux/arm/v7
102
+ - linux/arm64
80
103
steps :
81
104
- name : Checkout
82
- uses : actions/checkout@v3
105
+ uses : actions/checkout@v4
83
106
with :
84
107
fetch-depth : 0
85
108
86
109
- name : Login to GitHub Container Registry
87
- uses : docker/login-action@v2
110
+ uses : docker/login-action@v3
88
111
with :
89
- registry : ghcr.io
112
+ registry : ${{ env.REGISTRY }}
90
113
username : ${{ github.repository_owner }}
91
114
password : ${{ secrets.GITHUB_TOKEN }}
92
115
93
116
- name : Extract metadata
94
117
id : meta
95
- uses : docker/metadata-action@v4
118
+ uses : docker/metadata-action@v5
96
119
with :
97
- images : ghcr.io/autobrr/omegabrr
120
+ images : ${{ env.REGISTRY_IMAGE }}
121
+ tags : |
122
+ type=semver,pattern={{version}},prefix=v
123
+ type=semver,pattern={{major}}.{{minor}},prefix=v
124
+ type=ref,event=branch
125
+ type=ref,event=pr
126
+ flavor : |
127
+ latest=auto
98
128
99
129
- name : Set up QEMU
100
- uses : docker/setup-qemu-action@v2
130
+ uses : docker/setup-qemu-action@v3
101
131
102
132
- name : Set up Docker Buildx
103
- uses : docker/setup-buildx-action@v2
133
+ uses : docker/setup-buildx-action@v3
134
+
135
+ - name : Supported Architectures
136
+ run : docker buildx ls
104
137
105
138
- name : Build and publish image
106
139
id : docker_build
107
- uses : docker/build-push-action@v3
140
+ uses : docker/build-push-action@v5
108
141
with :
109
142
context : .
110
- file : ./Dockerfile
111
- platforms : linux/amd64,linux/arm/v7,linux/arm64/v8
112
- push : true
113
- tags : ${{ steps.meta.outputs.tags }}
143
+ file : ./Dockerfile.ci
144
+ platforms : ${{ matrix.platform }}
145
+ outputs : type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ (github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') && 'true' || 'false' }}
114
146
labels : ${{ steps.meta.outputs.labels }}
115
147
build-args : |
116
148
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
117
149
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
118
150
REVISION=${{ github.event.pull_request.head.sha }}
151
+ cache-from : type=gha
152
+ cache-to : type=gha,mode=max
153
+ provenance : false
154
+
155
+ - name : Export image digest
156
+ id : digest-prep
157
+ run : |
158
+ mkdir -p /tmp/digests
159
+ digest="${{ steps.docker_build.outputs.digest }}"
160
+ echo "manifest-hash=${digest#sha256:}" >> "$GITHUB_OUTPUT"
161
+ touch "/tmp/digests/${digest#sha256:}"
162
+
163
+ - name : Upload image digest
164
+ uses : actions/upload-artifact@v4
165
+ with :
166
+ name : docker-digests-${{ steps.digest-prep.outputs.manifest-hash }}
167
+ path : /tmp/digests/*
168
+ if-no-files-found : error
169
+ retention-days : 1
170
+
171
+ docker-merge :
172
+ name : Publish Docker multi-arch manifest
173
+ if : ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request' }}
174
+ runs-on : ubuntu-latest
175
+ needs : [docker, test]
176
+ steps :
177
+ - name : Download image digests
178
+ uses : actions/download-artifact@v4
179
+ with :
180
+ path : /tmp/digests
181
+ pattern : docker-digests-*
182
+ merge-multiple : true
183
+
184
+ - name : Set up Docker Buildx
185
+ uses : docker/setup-buildx-action@v3
119
186
120
- - name : Image digest
121
- run : echo ${{ steps.docker_build.outputs.digest }}
187
+ - name : Login to GitHub Container Registry
188
+ uses : docker/login-action@v3
189
+ with :
190
+ registry : ${{ env.REGISTRY }}
191
+ username : ${{ github.repository_owner }}
192
+ password : ${{ secrets.GITHUB_TOKEN }}
193
+
194
+ - name : Extract metadata
195
+ id : meta
196
+ uses : docker/metadata-action@v5
197
+ with :
198
+ images : ${{ env.REGISTRY_IMAGE }}
199
+ tags : |
200
+ type=semver,pattern={{version}},prefix=v
201
+ type=semver,pattern={{major}}.{{minor}},prefix=v
202
+ type=ref,event=branch
203
+ type=ref,event=pr
204
+ flavor : |
205
+ latest=auto
206
+
207
+ - name : Create manifest list and push
208
+ working-directory : /tmp/digests
209
+ run : |
210
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
211
+ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
212
+
213
+ - name : Inspect image
214
+ run : |
215
+ docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
0 commit comments