55 push :
66 branches :
77 - main
8+ - ' **'
89 tags :
910 - v*
1011 pull_request :
1112 branches :
1213 - main
1314
1415env :
16+ REGISTRY : ghcr.io
17+ IMAGE_NAME : ${{ github.repository }}
1518 PLATFORMS : |
1619 linux/arm/v7
1720 linux/arm64
1821 linux/amd64
19- TAGS : |
20- type=schedule
21- type=ref,event=branch
22- type=ref,event=tag
23- type=ref,event=pr
24- type=sha,prefix=,suffix=,format=long
2522
2623jobs :
2724 test :
2825 runs-on : ubuntu-24.04
2926 steps :
30- - name : Set up Go
31- uses : actions/setup-go@v3
32- with :
33- go-version : 1.24
34- - name : Checkout repo
35- uses : actions/checkout@v3
36- - name : Lint the codebase
37- uses : golangci/golangci-lint-action@v8
38- with :
39- version : latest
40- - name : Run tests
41- run : |
42- go test -v ./... -cover -race -coverprofile=coverage.out
43- go tool cover -func=coverage.out -o=coverage.out
27+ - name : Set up Go
28+ uses : actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
29+ with :
30+ go-version : " 1.25"
31+ - name : Checkout repo
32+ uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
33+ - name : Lint the codebase
34+ uses : golangci/golangci-lint-action@v8
35+ with :
36+ version : latest
37+ - name : Run tests
38+ run : |
39+ go test -v ./... -cover -race -coverprofile=coverage.out
40+ go tool cover -func=coverage.out -o=coverage.out
41+
4442 build :
4543 runs-on : ubuntu-24.04
4644 needs : test
45+ permissions :
46+ contents : read
47+ packages : write
4748 steps :
48- - name : Checkout repo
49- uses : actions/checkout@v3
50- - name : Set up QEMU
51- uses : docker/setup-qemu-action@v2
52- with :
53- platforms : all
54- - name : Set up Docker Buildx
55- id : buildx
56- uses : docker/setup-buildx-action@v2
57- with :
58- version : latest
59- - name : Login to Docker Hub
60- if : ${{ github.actor == github.repository_owner }}
61- uses : docker/login-action@v2
62- with :
63- username : ${{ secrets.DOCKER_USERNAME }}
64- password : ${{ secrets.DOCKER_PASSWORD }}
65- - name : Collect image metadata
66- id : meta
67- uses : docker/metadata-action@v4
68- with :
69- images : ${{ github.repository }}
70- tags : ${{ env.TAGS }}
71- - name : Collect build image metadata
72- id : buildmeta
73- uses : docker/metadata-action@v4
74- with :
75- images : ${{ github.repository }}-build-image
76- tags : ${{ env.TAGS }}
77- - name : Build and push release
78- uses : docker/build-push-action@v3
79- with :
80- context : .
81- push : ${{ github.actor == github.repository_owner }}
82- load : ${{ github.actor != github.repository_owner }}
83- tags : ${{ steps.meta.outputs.tags }}
84- labels : ${{ steps.meta.outputs.labels }}
85- target : release
86- cache-from : |
87- ${{ github.repository }}-cache
88- cache-to : |
89- ${{ github.actor == github.repository_owner && format('type=registry,ref={0}-cache,mode=max', github.repository) || '' }}
90- platforms : ${{ github.actor == github.repository_owner && env.PLATFORMS || 'linux/amd64' }}
91- build-args : |
92- DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
93- VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
94- COMMIT=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
95- REPOSITORY=${{ github.repository }}
96- - name : Build and push build image
97- uses : docker/build-push-action@v3
98- with :
99- context : .
100- push : ${{ github.actor == github.repository_owner }}
101- load : ${{ github.actor != github.repository_owner }}
102- tags : ${{ steps.buildmeta.outputs.tags }}
103- labels : ${{ steps.buildmeta.outputs.labels }}
104- target : build-image
105- cache-from : |
106- ${{ github.repository }}-cache
107- cache-to : |
108- ${{ github.actor == github.repository_owner && format('type=registry,ref={0}-cache,mode=max', github.repository) || '' }}
109- platforms : ${{ github.actor == github.repository_owner && env.PLATFORMS || 'linux/amd64' }}
110- build-args : |
111- DATE=${{ fromJSON(steps.buildmeta.outputs.json).labels['org.opencontainers.image.created'] }}
112- VERSION=${{ fromJSON(steps.buildmeta.outputs.json).labels['org.opencontainers.image.version'] }}
113- COMMIT=${{ fromJSON(steps.buildmeta.outputs.json).labels['org.opencontainers.image.revision'] }}
114- REPOSITORY=${{ github.repository }}
115- - name : Get version info
116- run : |
117- docker run --rm ${{ github.repository }}:${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} -v
49+ - name : Checkout repo
50+ uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
51+
52+ - name : Set up QEMU
53+ uses : docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
54+
55+ - name : Setup Docker buildx
56+ uses : docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
57+
58+ - name : Log into registry ${{ env.REGISTRY }}
59+ if : github.event_name != 'pull_request'
60+ uses : docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
61+ with :
62+ registry : ${{ env.REGISTRY }}
63+ username : ${{ github.actor }}
64+ password : ${{ secrets.GITHUB_TOKEN }}
65+
66+ - name : Extract Docker metadata
67+ id : meta
68+ uses : docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
69+ with :
70+ github-token : ${{ secrets.GITHUB_TOKEN }}
71+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
72+ tags : |
73+ type=ref,event=branch,prefix=
74+ type=ref,event=tag,prefix=
75+ type=sha,format=short,prefix=
76+ type=sha,format=long,prefix=
77+
78+ - name : Extract Docker metadata for build image
79+ id : buildmeta
80+ uses : docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
81+ with :
82+ github-token : ${{ secrets.GITHUB_TOKEN }}
83+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-build-image
84+ tags : |
85+ type=ref,event=branch,prefix=
86+ type=ref,event=tag,prefix=
87+ type=sha,format=short,prefix=
88+ type=sha,format=long,prefix=
89+
90+ - name : Build and push release
91+ uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
92+ with :
93+ context : .
94+ push : ${{ github.event_name != 'pull_request' }}
95+ load : ${{ github.event_name == 'pull_request' }}
96+ tags : ${{ steps.meta.outputs.tags }}
97+ labels : ${{ steps.meta.outputs.labels }}
98+ target : release
99+ platforms : ${{ github.event_name != 'pull_request' && env.PLATFORMS || 'linux/amd64' }}
100+ provenance : false
101+ cache-from : type=gha
102+ cache-to : type=gha,mode=max
103+ build-args : |
104+ DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
105+ VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
106+ COMMIT=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
107+ REPOSITORY=${{ github.repository }}
108+
109+ - name : Build and push build image
110+ uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
111+ with :
112+ context : .
113+ push : ${{ github.event_name != 'pull_request' }}
114+ load : ${{ github.event_name == 'pull_request' }}
115+ tags : ${{ steps.buildmeta.outputs.tags }}
116+ labels : ${{ steps.buildmeta.outputs.labels }}
117+ target : build-image
118+ platforms : ${{ github.event_name != 'pull_request' && env.PLATFORMS || 'linux/amd64' }}
119+ provenance : false
120+ cache-from : type=gha
121+ cache-to : type=gha,mode=max
122+ build-args : |
123+ DATE=${{ fromJSON(steps.buildmeta.outputs.json).labels['org.opencontainers.image.created'] }}
124+ VERSION=${{ fromJSON(steps.buildmeta.outputs.json).labels['org.opencontainers.image.version'] }}
125+ COMMIT=${{ fromJSON(steps.buildmeta.outputs.json).labels['org.opencontainers.image.revision'] }}
126+ REPOSITORY=${{ github.repository }}
127+
128+ - name : Get version info
129+ if : github.event_name == 'pull_request'
130+ run : |
131+ docker run --rm ${{ fromJSON(steps.meta.outputs.json).tags[0] }} -v
0 commit comments