mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-09-23 17:24:42 +08:00
chore(build): update dependencies, enhance cross-compilation, and refactor workflows
- Updated `golang.org/x/sys` to v0.38.0 in `go.mod` and replaced `syscall` with `windows` package for memory allocation in `loader_windows.go`. - Improved cross-compilation in `.goreleaser.yml` using Zig-based toolchains for better platform support. - Changed GitHub Actions workflow to use macOS runners and added Zig toolchain setup.
This commit is contained in:
5
.github/workflows/release.yaml
vendored
5
.github/workflows/release.yaml
vendored
@@ -11,7 +11,7 @@ permissions:
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -25,6 +25,9 @@ jobs:
|
||||
with:
|
||||
go-version: '>=1.26.0'
|
||||
cache: true
|
||||
- uses: mlugg/setup-zig@v2
|
||||
with:
|
||||
version: 0.16.0
|
||||
- name: Generate Build Metadata
|
||||
run: |
|
||||
echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
|
||||
|
||||
@@ -4,6 +4,32 @@ builds:
|
||||
- id: "cli-proxy-api"
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- >-
|
||||
{{- if eq .Os "linux" }}
|
||||
{{- if eq .Arch "amd64" }}CC=zig cc -target x86_64-linux-gnu{{- end }}
|
||||
{{- if eq .Arch "arm64" }}CC=zig cc -target aarch64-linux-gnu{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "freebsd" }}
|
||||
{{- if eq .Arch "amd64" }}CC=zig cc -target x86_64-freebsd{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "windows" }}
|
||||
{{- if eq .Arch "amd64" }}CC=zig cc -target x86_64-windows-gnu{{- end }}
|
||||
{{- if eq .Arch "arm64" }}CC=zig cc -target aarch64-windows-gnu{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "darwin" }}CC=clang{{- end }}
|
||||
- >-
|
||||
{{- if eq .Os "linux" }}
|
||||
{{- if eq .Arch "amd64" }}CXX=zig c++ -target x86_64-linux-gnu{{- end }}
|
||||
{{- if eq .Arch "arm64" }}CXX=zig c++ -target aarch64-linux-gnu{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "freebsd" }}
|
||||
{{- if eq .Arch "amd64" }}CXX=zig c++ -target x86_64-freebsd{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "windows" }}
|
||||
{{- if eq .Arch "amd64" }}CXX=zig c++ -target x86_64-windows-gnu{{- end }}
|
||||
{{- if eq .Arch "arm64" }}CXX=zig c++ -target aarch64-windows-gnu{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "darwin" }}CXX=clang++{{- end }}
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
@@ -12,18 +38,23 @@ builds:
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
ignore:
|
||||
- goos: freebsd
|
||||
goarch: arm64
|
||||
main: ./cmd/server/
|
||||
binary: cli-proxy-api
|
||||
ldflags:
|
||||
- -s -w -X 'main.Version={{.Version}}' -X 'main.Commit={{.ShortCommit}}' -X 'main.BuildDate={{.Date}}'
|
||||
archives:
|
||||
- id: "cli-proxy-api"
|
||||
format: tar.gz
|
||||
formats:
|
||||
- tar.gz
|
||||
name_template: >-
|
||||
{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{- if eq .Arch "arm64" -}}aarch64{{- else -}}{{ .Arch }}{{- end -}}
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
formats:
|
||||
- zip
|
||||
files:
|
||||
- LICENSE
|
||||
- README.md
|
||||
@@ -34,7 +65,7 @@ checksum:
|
||||
name_template: 'checksums.txt'
|
||||
|
||||
snapshot:
|
||||
name_template: "{{ incpatch .Version }}-next"
|
||||
version_template: "{{ incpatch .Version }}-next"
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
|
||||
2
go.mod
2
go.mod
@@ -27,6 +27,7 @@ require (
|
||||
golang.org/x/net v0.47.0
|
||||
golang.org/x/oauth2 v0.30.0
|
||||
golang.org/x/sync v0.18.0
|
||||
golang.org/x/sys v0.38.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
@@ -98,7 +99,6 @@ require (
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
golang.org/x/arch v0.8.0 // indirect
|
||||
golang.org/x/sys v0.38.0 // indirect
|
||||
golang.org/x/text v0.31.0 // indirect
|
||||
google.golang.org/protobuf v1.34.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
type windowsBuffer struct {
|
||||
@@ -179,7 +181,7 @@ func windowsHostCall(hostCtx uintptr, methodPtr uintptr, requestPtr uintptr, req
|
||||
if len(resp) == 0 || responsePtr == 0 {
|
||||
return 0
|
||||
}
|
||||
mem, errAlloc := syscall.LocalAlloc(0, uint32(len(resp)))
|
||||
mem, errAlloc := windows.LocalAlloc(windows.LMEM_FIXED, uint32(len(resp)))
|
||||
if errAlloc != nil || mem == 0 {
|
||||
return 1
|
||||
}
|
||||
@@ -192,7 +194,7 @@ func windowsHostCall(hostCtx uintptr, methodPtr uintptr, requestPtr uintptr, req
|
||||
|
||||
func windowsHostFree(ptr uintptr, len uintptr) uintptr {
|
||||
if ptr != 0 {
|
||||
_, _ = syscall.LocalFree(syscall.Handle(ptr))
|
||||
_, _ = windows.LocalFree(windows.Handle(ptr))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user