1212 default : false
1313
1414jobs :
15- build-linux :
16- name : Build Linux (CGO)
15+ build-linux-amd64 :
16+ name : Build Linux amd64 (CGO static musl )
1717 runs-on : ubuntu-latest
1818 steps :
1919 - uses : actions/checkout@v4
2020
21- - name : Set up Go
22- uses : actions/setup-go@v5
21+ - name : Build linux/amd64 static
22+ run : |
23+ set -euxo pipefail
24+ mkdir -p dist
25+ BIN="tlss-linux-amd64"
26+ docker run --rm \
27+ -v "${{ github.workspace }}:/app" \
28+ -w /app \
29+ golang:1.25-alpine \
30+ sh -c "apk add --no-cache gcc musl-dev && \
31+ CGO_ENABLED=1 go build -trimpath \
32+ -ldflags='-linkmode external -extldflags \"-static\" -s -w' \
33+ -o dist/${BIN} ."
34+ ls -l "dist/${BIN}"
35+ (cd dist && tar -czf "${BIN}.tar.gz" "${BIN}" && rm -f "${BIN}")
36+
37+ - name : Upload artifacts
38+ uses : actions/upload-artifact@v4
2339 with :
24- go-version : ' 1.25.3'
40+ name : bins-linux-amd64
41+ path : dist/*
42+ retention-days : 7
2543
26- - name : Install toolchains for CGO
27- run : |
28- set -eux
29- sudo apt-get update
30- sudo apt-get install -y build-essential pkg-config tar
31- # кросс-компилятор для linux/arm64
32- sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
33- # при необходимости внешние C-зависимости:
34- # sudo apt-get install -y libssl-dev
35-
36- - name : Build (linux amd64/arm64) with CGO
37- env :
38- CGO_ENABLED : " 1"
44+ build-linux-arm64 :
45+ name : Build Linux arm64 (CGO static musl)
46+ runs-on : ubuntu-24.04-arm
47+ steps :
48+ - uses : actions/checkout@v4
49+
50+ - name : Build linux/arm64 static
3951 run : |
4052 set -euxo pipefail
4153 mkdir -p dist
42- # GOOS GOARCH CC
43- targets=(
44- "linux amd64 gcc"
45- "linux arm64 aarch64-linux-gnu-gcc"
46- )
47- for t in "${targets[@]}"; do
48- read -r GOOS GOARCH CCNAME <<<"$t"
49- BIN="tlss-${GOOS}-${GOARCH}"
50- echo "==> Building ${BIN} with CC=${CCNAME}"
51- CC="$CCNAME" GOOS="$GOOS" GOARCH="$GOARCH" CGO_ENABLED=1 \
52- go build -trimpath -ldflags="-s -w" -o "dist/${BIN}" .
53- ls -l "dist/${BIN}"
54- (cd dist && tar -czf "${BIN}.tar.gz" "${BIN}" && rm -f "${BIN}")
55- done
56- ls -l dist
54+ BIN="tlss-linux-arm64"
55+ docker run --rm \
56+ -v "${{ github.workspace }}:/app" \
57+ -w /app \
58+ golang:1.25-alpine \
59+ sh -c "apk add --no-cache gcc musl-dev && \
60+ CGO_ENABLED=1 go build -trimpath \
61+ -ldflags='-linkmode external -extldflags \"-static\" -s -w' \
62+ -o dist/${BIN} ."
63+ ls -l "dist/${BIN}"
64+ (cd dist && tar -czf "${BIN}.tar.gz" "${BIN}" && rm -f "${BIN}")
5765
5866 - name : Upload artifacts
5967 uses : actions/upload-artifact@v4
6068 with :
61- name : bins-linux
69+ name : bins-linux-arm64
6270 path : dist/*
6371 retention-days : 7
6472
@@ -102,7 +110,7 @@ jobs:
102110 release :
103111 name : Create GitHub Release
104112 runs-on : ubuntu-latest
105- needs : [build-linux, build-macos]
113+ needs : [build-linux-amd64, build-linux-arm64 , build-macos]
106114 permissions :
107115 contents : write
108116
@@ -152,4 +160,4 @@ jobs:
152160 prerelease : ${{ inputs.prerelease }}
153161 files : upload/* # всё из временной папки
154162 env :
155- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
163+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments