@@ -178,24 +178,25 @@ jobs:
178178 with :
179179 ndk-version : r28
180180 - name : Clone cronet-go
181- if : matrix.naive
181+ if : matrix.naive && matrix.variant != 'purego'
182182 run : |
183183 set -xeuo pipefail
184184 CRONET_GO_VERSION=$(cat .github/CRONET_GO_VERSION)
185185 git init ~/cronet-go
186186 git -C ~/cronet-go remote add origin https://github.com/sagernet/cronet-go.git
187- git -C ~/cronet-go fetch --depth=1 origin "$CRONET_GO_VERSION"
187+ git -C ~/cronet-go sparse-checkout set --no-cone '/*' '!/lib'
188+ git -C ~/cronet-go fetch --depth=1 --filter=blob:none origin "$CRONET_GO_VERSION"
188189 git -C ~/cronet-go checkout FETCH_HEAD
189190 git -C ~/cronet-go submodule update --init --recursive --depth=1
190191 - name : Regenerate Debian keyring
191- if : matrix.naive
192+ if : matrix.naive && matrix.variant != 'purego'
192193 run : |
193194 set -xeuo pipefail
194195 rm -f ~/cronet-go/naiveproxy/src/build/linux/sysroot_scripts/keyring.gpg
195196 cd ~/cronet-go
196197 GPG_TTY=/dev/null ./naiveproxy/src/build/linux/sysroot_scripts/generate_keyring.sh
197198 - name : Download Chromium toolchain
198- if : matrix.naive
199+ if : matrix.naive && matrix.variant != 'purego'
199200 run : |
200201 set -xeuo pipefail
201202 cd ~/cronet-go
@@ -205,7 +206,7 @@ jobs:
205206 go run ./cmd/build-naive --target=linux/${{ matrix.arch }} download-toolchain
206207 fi
207208 - name : Set Chromium toolchain environment
208- if : matrix.naive
209+ if : matrix.naive && matrix.variant != 'purego'
209210 run : |
210211 set -xeuo pipefail
211212 cd ~/cronet-go
@@ -255,9 +256,15 @@ jobs:
255256 - name : Extract libcronet.so
256257 if : matrix.variant == 'purego' && matrix.naive
257258 run : |
258- cd ~/cronet-go
259- CGO_ENABLED=0 go build -v -o "$RUNNER_TEMP/build-naive" ./cmd/build-naive
260- GOPROXY=direct GOSUMDB=off "$RUNNER_TEMP/build-naive" extract-lib --target ${{ matrix.os }}/${{ matrix.arch }} -o $GITHUB_WORKSPACE/dist
259+ set -xeuo pipefail
260+ CRONET_GO_VERSION=$(cat .github/CRONET_GO_VERSION)
261+ LIBRARY_PATH="lib/${{ matrix.os }}_${{ matrix.arch }}/libcronet.so"
262+ git init "$RUNNER_TEMP/cronet-go-lib"
263+ git -C "$RUNNER_TEMP/cronet-go-lib" remote add origin https://github.com/sagernet/cronet-go.git
264+ git -C "$RUNNER_TEMP/cronet-go-lib" sparse-checkout set --no-cone "/$LIBRARY_PATH"
265+ git -C "$RUNNER_TEMP/cronet-go-lib" fetch --depth=1 --filter=blob:none origin "$CRONET_GO_VERSION"
266+ git -C "$RUNNER_TEMP/cronet-go-lib" checkout FETCH_HEAD
267+ cp "$RUNNER_TEMP/cronet-go-lib/$LIBRARY_PATH" dist/
261268 - name : Build (glibc)
262269 if : matrix.variant == 'glibc'
263270 run : |
@@ -624,15 +631,13 @@ jobs:
624631 if : matrix.naive
625632 run : |
626633 $CRONET_GO_VERSION = Get-Content .github/CRONET_GO_VERSION
627- git init "$env:RUNNER_TEMP/cronet-go"
628- git -C "$env:RUNNER_TEMP/cronet-go" remote add origin https://github.com/sagernet/cronet-go.git
629- git -C "$env:RUNNER_TEMP/cronet-go" fetch --depth=1 origin "$CRONET_GO_VERSION"
630- git -C "$env:RUNNER_TEMP/cronet-go" checkout FETCH_HEAD
631- $env:CGO_ENABLED = "0"
632- go -C "$env:RUNNER_TEMP/cronet-go" build -v -o "$env:RUNNER_TEMP/build-naive.exe" ./cmd/build-naive
633- $env:GOPROXY = "direct"
634- $env:GOSUMDB = "off"
635- & "$env:RUNNER_TEMP/build-naive.exe" extract-lib --target windows/${{ matrix.arch }} -o dist
634+ $LIBRARY_PATH = "lib/windows_${{ matrix.arch }}/libcronet.dll"
635+ git init "$env:RUNNER_TEMP/cronet-go-lib"
636+ git -C "$env:RUNNER_TEMP/cronet-go-lib" remote add origin https://github.com/sagernet/cronet-go.git
637+ git -C "$env:RUNNER_TEMP/cronet-go-lib" sparse-checkout set --no-cone "/$LIBRARY_PATH"
638+ git -C "$env:RUNNER_TEMP/cronet-go-lib" fetch --depth=1 --filter=blob:none origin "$CRONET_GO_VERSION"
639+ git -C "$env:RUNNER_TEMP/cronet-go-lib" checkout FETCH_HEAD
640+ Copy-Item "$env:RUNNER_TEMP/cronet-go-lib/$LIBRARY_PATH" dist
636641 - name : Archive
637642 if : matrix.naive
638643 run : |
0 commit comments