-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (71 loc) · 2.82 KB
/
binary-release.yml
File metadata and controls
82 lines (71 loc) · 2.82 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
name: Build and Release FanOut
on:
push:
tags:
- 'v*' # Trigger on any tag starting with 'v'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write # This is required for creating releases
packages: write # This is needed if you're also pushing to GHCR
steps:
- name: Check out code
uses: actions/checkout@v6
with:
fetch-depth: 0 # Fetch all history for proper versioning
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.24'
- name: Extract version info
id: version_info
run: |
# Extract version from tag (without 'v' prefix)
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
# Get commit hash
echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
# Generate build timestamp
echo "TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
- name: Run unit tests
run: |
go mod download
go test -v ./...
- name: Security scan (gosec)
run: |
docker run --rm -v ${{ github.workspace }}:/src -w /src securego/gosec:v2.22.4 gosec ./...
- name: Build for multiple platforms
run: |
mkdir -p dist
FLAGS="-s -w -X main.Version=$VERSION -X main.GitCommit=$COMMIT -X main.BuildTime=$TIMESTAMP"
# Build for Linux (amd64)
GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="$FLAGS" -o dist/fanout-linux-amd64
# Build for Linux (arm64)
GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="$FLAGS" -o dist/fanout-linux-arm64
# Build for Linux (armv7)
GOOS=linux GOARCH=arm GOARM=7 go build -trimpath -ldflags="$FLAGS" -o dist/fanout-linux-armv7
# Build for macOS (amd64)
GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags="$FLAGS" -o dist/fanout-darwin-amd64
# Build for macOS (arm64 - Apple Silicon)
GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags="$FLAGS" -o dist/fanout-darwin-arm64
# Build for Windows
GOOS=windows GOARCH=amd64 go build -trimpath -ldflags="$FLAGS" -o dist/fanout-windows-amd64.exe
# Create checksums
cd dist && sha256sum * > checksums.txt
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
files: |
dist/fanout-linux-amd64
dist/fanout-linux-arm64
dist/fanout-linux-armv7
dist/fanout-darwin-amd64
dist/fanout-darwin-arm64
dist/fanout-windows-amd64.exe
dist/checksums.txt
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}