4
4
push :
5
5
branches :
6
6
- master
7
+ - main
7
8
tags :
8
9
- ' [0-9]+.[0-9]+.[0-9]+'
9
10
paths-ignore :
15
16
- ' *.yaml'
16
17
17
18
jobs :
18
-
19
19
build :
20
20
if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
21
21
runs-on : ubuntu-latest
22
- container : golang:1.21-alpine
22
+ permissions :
23
+ contents : read
23
24
24
25
steps :
25
- - name : checkout
26
- uses : actions/checkout@v3
26
+ - name : Checkout code
27
+ uses : actions/checkout@v4
28
+ with :
29
+ fetch-depth : 0
30
+
31
+ - name : Set up Go
32
+ uses : actions/setup-go@v5
33
+ with :
34
+ go-version : ' 1.21'
35
+ cache : true
27
36
28
- - name : build
29
- shell : sh
37
+ - name : Build release binaries
30
38
env :
31
39
GOPROXY : https://proxy.golang.org
32
40
CGO_ENABLED : 0
33
41
run : |
34
- apk --update add ca-certificates tzdata make git bash
35
42
make release
36
43
37
- - uses : actions/upload-artifact@v3
44
+ - name : Upload build artifacts
45
+ uses : actions/upload-artifact@v4
38
46
with :
39
47
name : ' pumba-binaries'
40
48
path : .bin/**
41
-
49
+ retention-days : 7
42
50
43
51
create-release :
44
52
if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
45
- name : release
53
+ name : Create GitHub Release
46
54
needs : [ build ]
47
55
runs-on : ubuntu-latest
56
+ permissions :
57
+ contents : write # Required for creating releases
48
58
49
59
steps :
50
- - name : checkout
51
- uses : actions/checkout@v3
60
+ - name : Checkout code
61
+ uses : actions/checkout@v4
52
62
53
- - name : tag
63
+ - name : Get tag name
54
64
id : get_tag
55
- run : echo ::set-output name= git_tag:: ${GITHUB_REF/ refs\ /tags\//}
65
+ run : echo " git_tag= ${GITHUB_REF# refs/tags/}" >> $GITHUB_OUTPUT
56
66
57
- - uses : actions/download-artifact@v3
58
- id : download
67
+ - name : Download artifacts
68
+ uses : actions/ download-artifact@v4
59
69
with :
60
70
name : ' pumba-binaries'
61
71
path : ${{ github.workspace }}/.bin/
62
72
63
- - name : release
64
- uses : softprops/action-gh-release@v1
73
+ - name : Create GitHub Release
74
+ uses : softprops/action-gh-release@v2
65
75
with :
66
76
name : ${{ steps.get_tag.outputs.git_tag }}
67
77
tag_name : ${{ steps.get_tag.outputs.git_tag }}
68
78
prerelease : true
69
79
generate_release_notes : true
70
80
files : |
71
81
${{ github.workspace }}/.bin/**
72
- push :
82
+
83
+ push-docker :
73
84
if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
74
- name : push
85
+ name : Push Docker Image
75
86
runs-on : ubuntu-latest
87
+ permissions :
88
+ contents : read
89
+ packages : write # Required if pushing to GHCR
76
90
77
91
steps :
78
- - name : checkout
79
- uses : actions/checkout@v3
92
+ - name : Checkout code
93
+ uses : actions/checkout@v4
80
94
81
- - name : get tag
95
+ - name : Get tag name
82
96
id : get_tag
83
- run : echo ::set-output name= git_tag:: ${GITHUB_REF/ refs\ /tags\//}
97
+ run : echo " git_tag= ${GITHUB_REF# refs/tags/}" >> $GITHUB_OUTPUT
84
98
85
- -
uses : benjlevesque/ short[email protected]
99
+ - name : Get short SHA
86
100
id : short-sha
101
+ run : echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
87
102
88
- - name : setup buildx
89
- uses : docker/setup-buildx-action@v2
103
+ - name : Set up Docker Buildx
104
+ uses : docker/setup-buildx-action@v3
105
+ with :
106
+ platforms : linux/amd64,linux/arm64
107
+
108
+ - name : Set up QEMU
109
+ uses : docker/setup-qemu-action@v3
90
110
91
- - name : login to registry
92
- uses : docker/login-action@v2
111
+ - name : Login to Docker registry
112
+ uses : docker/login-action@v3
93
113
with :
94
114
username : ${{ secrets.DOCKER_ACCOUNT }}
95
115
password : ${{ secrets.DOCKER_TOKEN }}
96
116
97
- - name : build and push
98
- uses : docker/build-push-action@v4
117
+ - name : Build metadata
118
+ id : meta
119
+ uses : docker/metadata-action@v5
120
+ with :
121
+ images : ${{ secrets.DOCKER_ORG }}/pumba
122
+ tags : |
123
+ type=semver,pattern={{version}}
124
+ type=raw,value=latest
125
+
126
+ - name : Build and push
127
+ uses : docker/build-push-action@v5
99
128
with :
100
129
file : docker/Dockerfile
101
130
context : .
102
- # skip tests since emulator fails on multi-arch build due to buildx open issue https://github.com/docker/buildx/issues/1986
103
131
build-args : |
104
- BRANCH=${{ github.ref-name }}
132
+ BRANCH=${{ github.ref_name }}
105
133
COMMIT=${{ steps.short-sha.outputs.sha }}
106
134
SKIP_TESTS=true
107
135
platforms : |
108
136
linux/amd64
109
137
linux/arm64
110
138
push : true
111
- tags : |
112
- ${{ secrets.DOCKER_ORG }}/pumba:${{ steps.get_tag.outputs.git_tag }}
113
- ${{ secrets.DOCKER_ORG }}/pumba:latest
139
+ tags : ${{ steps.meta.outputs.tags }}
140
+ labels : ${{ steps.meta.outputs.labels }}
141
+ cache-from : type=gha
142
+ cache-to : type=gha,mode=max
143
+ provenance : true
144
+ sbom : true
0 commit comments