-
Notifications
You must be signed in to change notification settings - Fork 2
145 lines (125 loc) · 3.6 KB
/
ci.yml
File metadata and controls
145 lines (125 loc) · 3.6 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Go Build & Package
on:
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]
jobs:
test:
name: Lint, Test, Sec
runs-on: ubuntu-latest
container: debian:trixie
permissions:
contents: read
steps:
- name: Install System Dependencies
run: |
apt-get update && apt-get install -y git make curl bash binutils build-essential
git config --global --add safe.directory '*'
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
# Linting
- name: GolangCI-Lint
uses: golangci/golangci-lint-action@v9
with:
version: latest
# Security Scan (Gosec)
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: ./...
# Vulnerability Check
- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
# Testing (with race detector)
- name: Run Tests
run: |
go test -v -race -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
env:
CGO_ENABLED: 1
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
version: v0.10.0
build-and-package:
name: Build, Deb (${{ matrix.arch }})
needs: [test, shellcheck]
runs-on: ubuntu-latest
container: debian:trixie
strategy:
matrix:
arch: [amd64, arm64]
permissions:
contents: read
steps:
- name: Install System Dependencies
run: |
apt-get update && apt-get install -y git make curl bash binutils build-essential
git config --global --add safe.directory '*'
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
# Build Binary
- name: Build Binaries
run: make build ARCH=${{ matrix.arch }} LDFLAGS="-s -w"
- name: Determine Version
id: get_version
shell: bash
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
# Strip 'refs/tags/v' to get '0.2.0'
VERSION=${GITHUB_REF#refs/tags/v}
else
# Fallback for non-tag builds (e.g. 0.0.0-dev-a1b2c3d)
VERSION=0.0.0-dev-${GITHUB_SHA::7}
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
# Create Deb File
- name: Package Deb
run: make deb VERSION=${{ env.VERSION }} ARCH=${{ matrix.arch }}
# Upload the .deb file when tagged
- name: Upload Deb Artifact
uses: actions/upload-artifact@v6
if: startsWith(github.ref, 'refs/tags/v')
with:
name: deb-package-${{ matrix.arch }}
path: "*.deb"
if-no-files-found: error
release:
name: Release
needs: build-and-package
runs-on: ubuntu-latest
permissions:
contents: write
security-events: write
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v7
with:
pattern: deb-package-*
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: "*.deb"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}