Skip to content

Commit 1bf030b

Browse files
committed
💚 将darwin切换回xgo编译
1 parent 46a0304 commit 1bf030b

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

.github/workflows/release.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ jobs:
99
build-rotateproxy:
1010
runs-on: ubuntu-18.04
1111
steps:
12-
-
13-
name: Checkout
12+
- name: Checkout
1413
uses: actions/checkout@v2
1514
- name: Setup Zig
1615
uses: goto-bus-stop/setup-zig@v1
@@ -34,7 +33,6 @@ jobs:
3433
'linux 386 i386-linux-musl'
3534
'windows amd64 x86_64-windows-gnu'
3635
'windows 386 i386-windows-gnu'
37-
'darwin amd64 x86_64-macos-gnu'
3836
)
3937
IFS=$'\n'
4038
for i in ${configs[@]}
@@ -48,15 +46,29 @@ jobs:
4846
if [ "${goos}" = "windows" ];then
4947
ext='.exe'
5048
fi
49+
# ref: https://dev.to/kristoff/zig-makes-go-cross-compilation-just-work-29ho
5150
echo "goos: ${goos} goarch: ${goarch} libc: ${libc}"
5251
echo '#!/bin/sh' > "$HOME/.bin/zcc"
5352
echo '#!/bin/sh' > "$HOME/.bin/zxx"
5453
echo 'ZIG_LOCAL_CACHE_DIR="$HOME/tmp" zig cc -target '${libc}' $@' >> "$HOME/.bin/zcc"
55-
echo 'ZIG_LOCAL_CACHE_DIR="$HOME/tmp" zig c++ '${libc}' $@' >> "$HOME/.bin/zxx"
54+
echo 'ZIG_LOCAL_CACHE_DIR="$HOME/tmp" zig c++ -target '${libc}' $@' >> "$HOME/.bin/zxx"
5655
CGO_ENABLED=1 GOOS="${goos}" GOARCH="${goarch}" CC="zcc" CXX="zxx" go build -o "../../build/rotateproxy-${goos}-${goarch}${ext}" -trimpath -ldflags="-linkmode=external -extldflags=-static -s -w"
5756
done
58-
-
59-
name: Run GoReleaser
57+
- name: Build with xgo
58+
uses: crazy-max/ghaction-xgo@v1
59+
with:
60+
xgo_version: latest
61+
go_version: latest
62+
dest: build
63+
prefix: rotateproxy
64+
targets: darwin/386,darwin/amd64
65+
v: true
66+
x: false
67+
race: false
68+
ldflags: -s -w
69+
buildmode: default
70+
pkg: cmd/rotateproxy
71+
- name: Run GoReleaser
6072
uses: goreleaser/goreleaser-action@v2
6173
with:
6274
version: latest

0 commit comments

Comments
 (0)