Skip to content

Commit

Permalink
💚 将darwin切换回xgo编译
Browse files Browse the repository at this point in the history
  • Loading branch information
akkuman committed Jan 19, 2022
1 parent 46a0304 commit 1bf030b
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ jobs:
build-rotateproxy:
runs-on: ubuntu-18.04
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v2
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v1
Expand All @@ -34,7 +33,6 @@ jobs:
'linux 386 i386-linux-musl'
'windows amd64 x86_64-windows-gnu'
'windows 386 i386-windows-gnu'
'darwin amd64 x86_64-macos-gnu'
)
IFS=$'\n'
for i in ${configs[@]}
Expand All @@ -48,15 +46,29 @@ jobs:
if [ "${goos}" = "windows" ];then
ext='.exe'
fi
# ref: https://dev.to/kristoff/zig-makes-go-cross-compilation-just-work-29ho
echo "goos: ${goos} goarch: ${goarch} libc: ${libc}"
echo '#!/bin/sh' > "$HOME/.bin/zcc"
echo '#!/bin/sh' > "$HOME/.bin/zxx"
echo 'ZIG_LOCAL_CACHE_DIR="$HOME/tmp" zig cc -target '${libc}' $@' >> "$HOME/.bin/zcc"
echo 'ZIG_LOCAL_CACHE_DIR="$HOME/tmp" zig c++ '${libc}' $@' >> "$HOME/.bin/zxx"
echo 'ZIG_LOCAL_CACHE_DIR="$HOME/tmp" zig c++ -target '${libc}' $@' >> "$HOME/.bin/zxx"
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"
done
-
name: Run GoReleaser
- name: Build with xgo
uses: crazy-max/ghaction-xgo@v1
with:
xgo_version: latest
go_version: latest
dest: build
prefix: rotateproxy
targets: darwin/386,darwin/amd64
v: true
x: false
race: false
ldflags: -s -w
buildmode: default
pkg: cmd/rotateproxy
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
Expand Down

0 comments on commit 1bf030b

Please sign in to comment.