From c53b894cc46f9cab68fe304e0f38f919da6226cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 12 Feb 2025 08:31:21 +0800 Subject: [PATCH] Build legacy binaries with latest Go Bump version --- .github/setup_legacy_go.sh | 22 ++++++++++++++++++++++ .github/workflows/build.yml | 9 +++------ .goreleaser.yaml | 4 ++-- 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100755 .github/setup_legacy_go.sh diff --git a/.github/setup_legacy_go.sh b/.github/setup_legacy_go.sh new file mode 100755 index 00000000..200f6d41 --- /dev/null +++ b/.github/setup_legacy_go.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +VERSION="1.23.6" +wget "https://dl.google.com/go/go${VERSION}.linux-amd64.tar.gz" +tar -xzf "go${VERSION}.linux-amd64.tar.gz" +mv go $HOME/go/go_legacy +cd $HOME/go/go_legacy + +# modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557 +# this patch file only works on golang1.23.x +# that means after golang1.24 release it must be changed +# see: https://github.com/MetaCubeX/go/commits/release-branch.go1.23/ +# revert: +# 693def151adff1af707d82d28f55dba81ceb08e1: "crypto/rand,runtime: switch RtlGenRandom for ProcessPrng" +# 7c1157f9544922e96945196b47b95664b1e39108: "net: remove sysSocket fallback for Windows 7" +# 48042aa09c2f878c4faa576948b07fe625c4707a: "syscall: remove Windows 7 console handle workaround" +# a17d959debdb04cd550016a3501dd09d50cd62e7: "runtime: always use LoadLibraryEx to load system libraries" + +curl https://github.com/MetaCubeX/go/commit/9ac42137ef6730e8b7daca016ece831297a1d75b.diff | patch --verbose -p 1 +curl https://github.com/MetaCubeX/go/commit/21290de8a4c91408de7c2b5b68757b1e90af49dd.diff | patch --verbose -p 1 +curl https://github.com/MetaCubeX/go/commit/6a31d3fa8e47ddabc10bd97bff10d9a85f4cfb76.diff | patch --verbose -p 1 +curl https://github.com/MetaCubeX/go/commit/69e2eed6dd0f6d815ebf15797761c13f31213dd6.diff | patch --verbose -p 1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61f14cfb..6eb8613c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -141,14 +141,11 @@ jobs: uses: actions/cache@v4 with: path: | - ~/go/go1.20.14 - key: go120 + ~/go/go_legacy + key: go_legacy_1236 - name: Setup legacy Go if: matrix.require_legacy_go && steps.cache-legacy-go.outputs.cache-hit != 'true' - run: |- - wget https://dl.google.com/go/go1.20.14.linux-amd64.tar.gz - tar -xzf go1.20.14.linux-amd64.tar.gz - mv go $HOME/go/go1.20.14 + run: bash .github/setup_legacy_go.sh - name: Setup Android NDK if: matrix.goos == 'android' uses: nttld/setup-ndk@v1 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 9eb02c94..fc0f4725 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -51,8 +51,8 @@ builds: - with_clash_api env: - CGO_ENABLED=0 - - GOROOT={{ .Env.GOPATH }}/go1.20.14 - tool: "{{ .Env.GOPATH }}/go1.20.14/bin/go" + - GOROOT={{ .Env.GOPATH }}/go_legacy + tool: "{{ .Env.GOPATH }}/go_legacy/bin/go" targets: - windows_amd64_v1 - windows_386