-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (77 loc) · 2.57 KB
/
build.yml
File metadata and controls
96 lines (77 loc) · 2.57 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
name: Build
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Build binaries
working-directory: ./eventgen
run: |
VERSION=${GITHUB_REF_NAME:-dev}
BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS="-s -w -X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}"
echo "Building version: $VERSION"
# Linux AMD64
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" -o bin/qcr-linux-amd64 ./cmd/main.go
# Linux ARM64
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$LDFLAGS" -o bin/qcr-linux-arm64 ./cmd/main.go
# macOS AMD64
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" -o bin/qcr-darwin-amd64 ./cmd/main.go
# macOS ARM64 (Apple Silicon)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="$LDFLAGS" -o bin/qcr-darwin-arm64 ./cmd/main.go
# Windows AMD64
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" -o bin/qcr-windows-amd64.exe ./cmd/main.go
ls -la bin/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: qcr-binaries
path: eventgen/bin/qcr-*
docker:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker images
working-directory: ./eventgen
run: |
docker build --target production -t qualys/qcr:latest .
docker build --target eventgen -t qualys/qcr-eventgen:latest .
release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: qcr-binaries
path: bin/
- name: Create checksums
run: |
cd bin
sha256sum qcr-* > checksums.txt
cat checksums.txt
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
bin/qcr-*
bin/checksums.txt
generate_release_notes: true