-
Notifications
You must be signed in to change notification settings - Fork 3
94 lines (77 loc) · 2.21 KB
/
build-and-release.yml
File metadata and controls
94 lines (77 loc) · 2.21 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
85
86
87
88
89
90
91
92
93
94
name: CI
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
permissions:
contents: read
jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Download dependencies
run: go mod download
- name: Vet
run: go vet ./...
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
- name: Build
run: CGO_ENABLED=0 go build -o kshark ./cmd/kshark
- name: Test
run: go test ./... -v -race -timeout 120s -coverprofile=coverage.out
- name: Coverage report
run: go tool cover -func=coverage.out
- name: Coverage gate
run: |
TOTAL=$(go tool cover -func=coverage.out | grep '^total:' | awk '{print substr($3, 1, length($3)-1)}')
echo "Total coverage: ${TOTAL}%"
THRESHOLD=40
if [ "$(echo "$TOTAL < $THRESHOLD" | bc)" -eq 1 ]; then
echo "::error::Coverage ${TOTAL}% is below ${THRESHOLD}% minimum"
exit 1
fi
- name: Vulnerability check
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
release:
name: Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write # Required for keyless cosign signing via GitHub OIDC
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Install syft (SBOM generator)
uses: anchore/sbom-action/download-syft@v0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}