Browse Source

Build legacy binaries with latest Go

世界 8 months ago
parent
commit
8aaaa06d92
3 changed files with 29 additions and 12 deletions
  1. 22 0
      .github/setup_legacy_go.sh
  2. 3 7
      .github/workflows/build.yml
  3. 4 5
      .goreleaser.yaml

+ 22 - 0
.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

+ 3 - 7
.github/workflows/build.yml

@@ -112,7 +112,6 @@ jobs:
           - name: darwin_amd64
             goos: darwin
             goarch: amd64
-            require_legacy_go: true
           - name: android_arm64
             goos: android
             goarch: arm64
@@ -141,14 +140,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

+ 4 - 5
.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:
@@ -124,8 +123,8 @@ nfpms:
       - deb
       - rpm
       - archlinux
-#      - apk
-#      - ipk
+    #      - apk
+    #      - ipk
     priority: extra
     contents:
       - src: release/config/config.json