From 511684d28998752ded6873380ddb6afe5bb47ec8 Mon Sep 17 00:00:00 2001 From: Ebrahim Tahernejad Date: Wed, 21 Jan 2026 19:10:13 +0330 Subject: [PATCH] Use MSYS2 to fix the runtime CGO problem --- .github/workflows/release.yml | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a744b9f3..65727bc5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -173,14 +173,35 @@ jobs: go-version-file: go.mod check-latest: true + - name: Install MSYS2 + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: >- + mingw-w64-x86_64-gcc + mingw-w64-x86_64-sqlite3 + mingw-w64-x86_64-pkg-config + + - name: Build 3X-UI for Windows (CGO) + shell: msys2 {0} + run: | + export PATH="/c/hostedtoolcache/windows/go/$(ls /c/hostedtoolcache/windows/go | sort -V | tail -n1)/x64/bin:$PATH" + + export CGO_ENABLED=1 + export GOOS=windows + export GOARCH=amd64 + export CC=x86_64-w64-mingw32-gcc + + which go + go version + gcc --version + + go build -ldflags "-w -s" -o xui-release.exe -v main.go + - name: Build 3X-UI for Windows shell: pwsh - run: | - $env:CGO_ENABLED="1" - $env:GOOS="windows" - $env:GOARCH="amd64" - go build -ldflags "-w -s" -o xui-release.exe -v main.go - + run: | mkdir x-ui Copy-Item xui-release.exe x-ui\ mkdir x-ui\bin