-
-
Notifications
You must be signed in to change notification settings - Fork 60
115 lines (101 loc) · 3.04 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: ci
on:
push:
pull_request:
types: [ opened, reopened ]
env:
REGISTRY: ghcr.io
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --timeout 3m0s
test:
strategy:
fail-fast: false
matrix:
platform: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go with cache
uses: actions/setup-go@v5
with:
cache: true
go-version-file: go.mod
- name: Test
run: make test
build:
if: ( github.event_name == 'push' && ( github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') ) )
needs:
- lint
- test
runs-on: ubuntu-latest
outputs:
image: ${{ steps.image-ref.outputs.image }}
image_latest: ${{ steps.image-ref.outputs.image_latest }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up docker buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create image ref
id: image-ref
run: |
REF=$(git rev-parse --short $GITHUB_SHA)
IMAGE=${{ env.REGISTRY }}/${{ github.repository }}:${REF}
IMAGE_LATEST=${{ env.REGISTRY }}/${{ github.repository }}:latest
echo "image=${IMAGE}" >> $GITHUB_STATE
echo "image_latest=${IMAGE_LATEST}" >> $GITHUB_OUTPUT
echo "${IMAGE}" >> $GITHUB_STEP_SUMMARY
- name: Build and push docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64,windows/amd64,windows/arm64,darwin/amd64,darwin/arm64,linux/arm/v7,linux/arm/v8,linux/s390x
cache-from: type=registry,ref=${{ steps.image-ref.outputs.image_latest }}
cache-to: type=inline
tags: |
${{ steps.image-ref.outputs.image }}
${{ steps.image-ref.outputs.image_latest }}
releaser:
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: true
go-version-file: go.mod
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}