1
- on : [push, pull_request]
2
1
name : CI
2
+ on :
3
+ pull_request : {}
4
+ push : {}
5
+ permissions : write-all
3
6
jobs :
4
7
# ================
5
- # TEST JOB
6
- # runs on every push and PR
7
- # runs 2x3 times (see matrix)
8
+ # BUILD AND TEST JOB
8
9
# ================
9
10
test :
10
- name : Test
11
+ name : Build & Test
11
12
strategy :
12
13
matrix :
13
- go-version : [1.21.x]
14
- platform : [ubuntu-latest]
14
+ # optionally test/build across multiple platforms/Go-versions
15
+ go-version : ["stable"] # '1.16', '1.17', '1.18,
16
+ platform : [ubuntu-latest, macos-latest, windows-latest]
15
17
runs-on : ${{ matrix.platform }}
16
18
steps :
17
- - name : Install Go
19
+ - name : Checkout
20
+ uses : actions/checkout@v3
21
+ with :
22
+ fetch-depth : 0
23
+ - name : Set up Go
18
24
uses : actions/setup-go@v3
19
25
with :
20
26
go-version : ${{ matrix.go-version }}
21
- - name : Checkout code
22
- uses : actions/checkout@v3
27
+ check-latest : true
23
28
- name : Build
24
29
run : go build -v -o /dev/null .
25
30
- name : Test
26
- run : go test -v ./...
31
+ run : go test -v ./...
32
+ # ================
33
+ # RELEASE BINARIES (on push "v*" tag)
34
+ # ================
35
+ release_binaries :
36
+ name : Release Binaries
37
+ needs : test
38
+ if : startsWith(github.ref, 'refs/tags/v')
39
+ runs-on : ubuntu-latest
40
+ steps :
41
+ - name : Check out code
42
+ uses : actions/checkout@v3
43
+ - name : goreleaser
44
+ if : success()
45
+ uses : docker://goreleaser/goreleaser:latest
46
+ env :
47
+ GITHUB_USER : ${{ github.repository_owner }}
48
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
49
+ with :
50
+ args : release --config .github/goreleaser.yml
51
+ # ================
52
+ # RELEASE DOCKER IMAGES (on push "v*" tag)
53
+ # ================
54
+ release_docker :
55
+ name : Release Docker Images
56
+ needs : test
57
+ if : startsWith(github.ref, 'refs/tags/v')
58
+ runs-on : ubuntu-latest
59
+ steps :
60
+ - name : Check out code
61
+ uses : actions/checkout@v3
62
+ - name : Set up QEMU
63
+ uses : docker/setup-qemu-action@v2
64
+ - name : Set up Docker Buildx
65
+ uses : docker/setup-buildx-action@v2
66
+ - name : Login to DockerHub
67
+ uses : docker/login-action@v2
68
+ with :
69
+ username : jpillora
70
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
71
+ - name : Docker meta
72
+ id : meta
73
+ uses : docker/metadata-action@v4
74
+ with :
75
+ images : jpillora/chisel
76
+ tags : |
77
+ type=semver,pattern={{version}}
78
+ type=semver,pattern={{major}}.{{minor}}
79
+ type=semver,pattern={{major}}
80
+ - name : Build and push
81
+ uses : docker/build-push-action@v3
82
+ with :
83
+ context : .
84
+ file : .github/Dockerfile
85
+ platforms : linux/amd64,linux/arm64,linux/ppc64le,linux/386,linux/arm/v7,linux/arm/v6
86
+ push : true
87
+ tags : ${{ steps.meta.outputs.tags }}
88
+ labels : ${{ steps.meta.outputs.labels }}
89
+ cache-from : type=gha
90
+ cache-to : type=gha,mode=max
0 commit comments