From 1bf030b8cc5017e7c996b39e88185a37355ab65a Mon Sep 17 00:00:00 2001 From: Akkuman Date: Wed, 19 Jan 2022 14:50:53 +0800 Subject: [PATCH] =?UTF-8?q?:green=5Fheart:=20=E5=B0=86darwin=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=9B=9Exgo=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca2f88c..59cae89 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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[@]} @@ -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