@@ -3,39 +3,45 @@ name: Build, Test, & Publish
3
3
on :
4
4
push :
5
5
branches : [ main ]
6
+ paths-ignore :
7
+ - " **.md"
8
+ - " LICENSE"
6
9
pull_request :
7
10
branches : [ main ]
8
-
9
- env :
10
- GO_VERSION : ~1.22
11
+ paths-ignore :
12
+ - " **.md "
13
+ - " LICENSE "
11
14
12
15
jobs :
13
16
unit_tests :
14
- name : unit tests
17
+ name : Unit tests
15
18
runs-on : ubuntu-latest
16
19
steps :
17
20
- uses : actions/checkout@v4
21
+
18
22
- name : Setup Go
19
23
uses : actions/setup-go@v5
20
24
with :
21
- go-version : ${{ env.GO_VERSION }}
22
- check-latest : true
25
+ go-version-file : go.mod
26
+
23
27
- name : Unit tests
24
28
run : go test -v ./...
29
+
25
30
build_dev_image :
26
- name : build dev image
31
+ name : Build dev image
27
32
runs-on : ubuntu-latest
28
33
needs : unit_tests
29
34
permissions :
30
35
contents : ' write'
31
36
id-token : ' write'
32
37
steps :
33
38
- uses : actions/checkout@v4
39
+
34
40
- name : Setup Go
35
41
uses : actions/setup-go@v5
36
42
with :
37
- go-version : ${{ env.GO_VERSION }}
38
- check-latest : true
43
+ go-version-file : go.mod
44
+
39
45
- name : OCI Metadata for multi-arch image
40
46
id : meta
41
47
uses : docker/metadata-action@v5
@@ -46,28 +52,35 @@ jobs:
46
52
type=sha
47
53
type=ref,event=pr
48
54
type=semver,pattern={{version}}
55
+
49
56
- uses : docker/setup-qemu-action@v3
57
+
50
58
- uses : docker/setup-buildx-action@v3
51
- - if : github.event_name != 'pull_request'
52
- uses : docker/login-action@v3
59
+
60
+ - uses : docker/login-action@v3
61
+ if : ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
53
62
with :
54
63
username : ${{ secrets.DOCKERHUB_USERNAME }}
55
64
password : ${{ secrets.DOCKERHUB_TOKEN }}
65
+
66
+ # We want to always build the image, and push to registry only on new tag i.e. new release
56
67
- name : Build and push
57
68
uses : docker/build-push-action@v6
58
69
with :
59
70
context : .
60
71
platforms : linux/amd64, linux/arm64, linux/ppc64le, linux/s390x
61
- push : ${{ github.event_name != 'pull_request' }}
72
+ push : ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }}
62
73
tags : ${{ steps.meta.outputs.tags }}
63
74
labels : ${{ steps.meta.outputs.labels }}
75
+
64
76
release :
65
77
name : Release to GitHub Releases
66
- runs-on : ubunut -latest
78
+ runs-on : ubuntu -latest
67
79
if : startsWith(github.ref, 'refs/tags/v')
68
80
needs : [ unit_tests, build_dev_image ]
69
81
steps :
70
82
- uses : actions/checkout@v4
83
+
71
84
- name : Release
72
85
uses : softprops/action-gh-release@v2
73
86
if : startsWith(github.ref, 'refs/tags/v')
0 commit comments