-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (61 loc) · 1.96 KB
/
Copy pathrelease.yml
File metadata and controls
73 lines (61 loc) · 1.96 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24' # Minimum 1.24 for dependencies
cache: true
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build binaries
env:
VERSION: ${{ steps.get_version.outputs.VERSION }}
CGO_ENABLED: "0"
run: |
mkdir -p dist
# Derived from the tagged commit, not from the clock, so rebuilding
# the same tag produces byte-identical binaries.
BUILD_DATE=$(git show -s --format=%cI "${GITHUB_SHA}")
LDFLAGS="-s -w -X main.version=${VERSION} -X main.commit=${GITHUB_SHA} -X main.date=${BUILD_DATE}"
build() {
GOOS=$1 GOARCH=$2 go build -trimpath -ldflags="${LDFLAGS}" -o "dist/$3" .
}
build linux amd64 netdiag-linux-amd64
build linux arm64 netdiag-linux-arm64
build darwin amd64 netdiag-darwin-amd64
build darwin arm64 netdiag-darwin-arm64
build windows amd64 netdiag-windows-amd64.exe
- name: Generate checksums
working-directory: dist
run: |
sha256sum * > checksums.txt
cat checksums.txt
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/netdiag-linux-amd64
dist/netdiag-linux-arm64
dist/netdiag-darwin-amd64
dist/netdiag-darwin-arm64
dist/netdiag-windows-amd64.exe
dist/checksums.txt
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}