diff --git a/.github/setup_legacy_go.sh b/.github/setup_legacy_go.sh new file mode 100755 index 00000000..3f1a31ad --- /dev/null +++ b/.github/setup_legacy_go.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +VERSION="1.23.6" + +mkdir -p $HOME/go +cd $HOME/go +wget "https://dl.google.com/go/go${VERSION}.linux-amd64.tar.gz" +tar -xzf "go${VERSION}.linux-amd64.tar.gz" +mv go go_legacy +cd 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 211743fa..349a5707 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,7 +86,6 @@ jobs: - { os: windows, arch: "386", legacy_go: true } - { os: windows, arch: amd64, legacy_go: true } - - { os: darwin, arch: amd64, legacy_go: true } - { os: android, arch: "386", ndk: "i686-linux-android21" } - { os: android, arch: amd64, ndk: "x86_64-linux-android21" } @@ -99,16 +98,28 @@ jobs: uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 with: fetch-depth: 0 - - name: Setup Go - if: matrix.legacy_go - uses: actions/setup-go@v5 - with: - go-version: ~1.20 - name: Setup Go if: ${{ ! matrix.legacy_go }} uses: actions/setup-go@v5 with: go-version: ^1.24 + - name: Cache Legacy Go + if: matrix.require_legacy_go + id: cache-legacy-go + uses: actions/cache@v4 + with: + path: | + ~/go/go_legacy + key: go_legacy_1236 + - name: Setup Legacy Go + if: matrix.legacy_go && steps.cache-legacy-go.outputs.cache-hit != 'true' + run: |- + .github/setup_legacy_go.sh + - name: Setup Legacy Go 2 + if: matrix.legacy_go + run: |- + echo "PATH=$HOME/go/go_legacy/bin:$PATH" >> $GITHUB_ENV + echo "GOROOT=$HOME/go/go_legacy" >> $GITHUB_ENV - name: Setup Android NDK if: matrix.os == 'android' uses: nttld/setup-ndk@v1 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 3ada7377..625276fa 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -51,12 +51,11 @@ 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 - - darwin_amd64_v1 - id: android <<: *template env: