-
Notifications
You must be signed in to change notification settings - Fork 39
84 lines (70 loc) · 1.93 KB
/
ci.yaml
File metadata and controls
84 lines (70 loc) · 1.93 KB
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
name: CI
on:
pull_request:
push:
branches:
- main
env:
CGO_ENABLED: 0
GO_VERSION: '1.25'
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
validate:
name: "Validate ${{ matrix.target }}"
runs-on: ubuntu-latest
strategy:
matrix:
target: ["verify", "lint", "test"]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- uses: actions/cache@v4
with:
path: bin
key: ${{ runner.os }}-tools-bin-${{ matrix.target }}-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-tools-bin-${{ matrix.target }}-
${{ runner.os }}-tools-bin-
- name: ${{ matrix.target }}
run: make ${{ matrix.target }}
build:
name: Build binaries and container images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- name: Build
run: make build-image
build-push-image:
name: Build and push image
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- validate
- build
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-tags: true
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
- uses: ko-build/setup-ko@v0.9
- run: ko login ${{ env.REGISTRY }} -u ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
run: make build-image-push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IS_RELEASE: true
GORELEASER_EXTRA_FLAGS: "--clean --skip=validate"