-
-
Notifications
You must be signed in to change notification settings - Fork 50
99 lines (81 loc) · 2.5 KB
/
build.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
name: Go Cross-Platform Build
on:
push:
paths-ignore:
- 'docs/**'
- 'README.md'
branches:
- main
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
branches:
- main
permissions:
contents: read
jobs:
makefile-build:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.21', '1.22', '1.23']
steps:
- uses: actions/checkout@v4
- name: Configure environment to avoid toolchain installs
shell: bash
run: echo "GOTOOLCHAIN=local" >> "$GITHUB_ENV"
- uses: actions/setup-go@v5
with:
go-version: "${{ matrix.go-version }}"
- name: build binary from makefile
run: make build
- name: dep from makefile
run: make dep
- name: dep+build from makefile
run: make
go-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: ['1.21', '1.22', '1.23']
goos: [linux, freebsd, darwin, windows]
exclude:
- { os: macos-latest, goos: linux }
- { os: macos-latest, goos: freebsd }
- { os: macos-latest, goos: windows }
- { os: ubuntu-latest, goos: darwin }
- { os: ubuntu-latest, goos: windows }
- { os: windows-latest, goos: linux }
- { os: windows-latest, goos: freebsd }
- { os: windows-latest, goos: darwin }
steps:
- uses: actions/checkout@v4
- name: Configure environment to avoid toolchain installs
shell: bash
run: echo "GOTOOLCHAIN=local" >> "$GITHUB_ENV"
- uses: actions/setup-go@v5
with:
go-version: "${{ matrix.go-version }}"
- name: Build binary
run: |
if [[ "${{ matrix.os }}" == 'windows-latest' ]]; then
set CGO_ENABLED=0
go build -ldflags="-s -w" -o go-dnscollector.exe .
else
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=amd64 go build -ldflags="-s -w" -o go-dnscollector *.go
fi
shell: bash
docker-build:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [linux/amd64, linux/386]
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: |
PLATFORM=${{ matrix.platform }}
TAG=$(echo "$PLATFORM" | tr '/' '-')
docker build --build-arg VERSION=dev . --platform $PLATFORM --file Dockerfile -t go-dnscollector:$TAG