-
Notifications
You must be signed in to change notification settings - Fork 5
71 lines (62 loc) · 1.86 KB
/
release.yml
File metadata and controls
71 lines (62 loc) · 1.86 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
if: github.server_url == 'https://github.com'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.26'
- name: Run tests
run: go test ./...
- name: Build binaries
run: |
VERSION=${GITHUB_REF_NAME}
LDFLAGS="-s -w -X main.version=${VERSION}"
targets=(
"linux/amd64"
"linux/arm64"
"linux/arm"
"darwin/amd64"
"darwin/arm64"
"windows/amd64"
"freebsd/amd64"
"freebsd/arm64"
)
mkdir -p dist
for target in "${targets[@]}"; do
GOOS="${target%/*}"
GOARCH="${target#*/}"
output="dist/dssh-${GOOS}-${GOARCH}"
if [ "$GOOS" = "windows" ]; then
output="dist/dssh.exe"
fi
echo "Building ${GOOS}/${GOARCH}..."
CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \
go build -ldflags="$LDFLAGS" -o "$output" ./cmd/dssh/
done
- name: Create tar.gz archives for macOS binaries
run: |
VERSION=${GITHUB_REF_NAME}
for arch in amd64 arm64; do
tar -czf "dist/dssh-darwin-${arch}.tar.gz" -C dist "dssh-darwin-${arch}"
done
- name: Compress Linux binaries with UPX
run: |
sudo apt-get update && sudo apt-get install -y upx
for f in dist/dssh-linux-*; do
echo "Compressing $f..."
upx --best "$f" || echo "UPX failed for $f, using uncompressed"
done
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: dist/*