From 511684d28998752ded6873380ddb6afe5bb47ec8 Mon Sep 17 00:00:00 2001 From: Ebrahim Tahernejad Date: Wed, 21 Jan 2026 19:10:13 +0330 Subject: [PATCH 1/4] 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 From a6ca391ba198b1b41e64f292905c4a58c29a5198 Mon Sep 17 00:00:00 2001 From: Ebrahim Tahernejad Date: Sat, 24 Jan 2026 16:57:19 +0330 Subject: [PATCH 2/4] macOS build workflow --- .github/workflows/release.yml | 90 +++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65727bc5..733dc9f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -151,6 +151,96 @@ jobs: overwrite: true prerelease: true + # ================================= + # macOS Build (darwin) + # ================================= + build-macos: + name: Build for macOS + permissions: + contents: write + strategy: + matrix: + include: + - arch: amd64 + runner: macos-13 + - arch: arm64 + runner: macos-14 + runs-on: ${{ matrix.runner }} + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Setup Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + check-latest: true + + - name: Build 3X-UI for macOS (CGO) + shell: bash + run: | + set -euo pipefail + export CGO_ENABLED=1 + export GOOS=darwin + export GOARCH=${{ matrix.arch }} + + go version + go env GOOS GOARCH CGO_ENABLED + + go build -ldflags "-w -s" -o xui-release -v main.go + file xui-release + + mkdir -p x-ui/bin + cp xui-release x-ui/x-ui + cp x-ui.sh x-ui/ + + # Download dependencies + cd x-ui/bin + Xray_URL="https://github.com/XTLS/Xray-core/releases/download/v26.1.18/" + if [ "${{ matrix.arch }}" = "amd64" ]; then + curl -fsSL -o Xray-macos-64.zip "${Xray_URL}Xray-macos-64.zip" + unzip -q Xray-macos-64.zip + rm -f Xray-macos-64.zip + elif [ "${{ matrix.arch }}" = "arm64" ]; then + curl -fsSL -o Xray-macos-arm64-v8a.zip "${Xray_URL}Xray-macos-arm64-v8a.zip" + unzip -q Xray-macos-arm64-v8a.zip + rm -f Xray-macos-arm64-v8a.zip + fi + + rm -f geoip.dat geosite.dat + curl -fsSL -o geoip.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat + curl -fsSL -o geosite.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat + curl -fsSL -o geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat + curl -fsSL -o geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat + curl -fsSL -o geoip_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat + curl -fsSL -o geosite_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat + + mv xray xray-macos-${{ matrix.arch }} + cd ../.. + + - name: Package + shell: bash + run: tar -zcvf x-ui-darwin-${{ matrix.arch }}.tar.gz x-ui + + - name: Upload files to Artifacts + uses: actions/upload-artifact@v4 + with: + name: x-ui-darwin-${{ matrix.arch }} + path: ./x-ui-darwin-${{ matrix.arch }}.tar.gz + + - name: Upload files to GH release + uses: svenstaro/upload-release-action@v2 + if: | + (github.event_name == 'release' && github.event.action == 'published') || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + file: x-ui-darwin-${{ matrix.arch }}.tar.gz + asset_name: x-ui-darwin-${{ matrix.arch }}.tar.gz + overwrite: true + prerelease: true + # ================================= # Windows Build # ================================= From 32d063706a1c0f3ff3fe7d7a615a1030fd7a85ef Mon Sep 17 00:00:00 2001 From: Ebrahim Tahernejad Date: Sun, 1 Feb 2026 13:06:26 +0330 Subject: [PATCH 3/4] Remove macOS build steps and update Windows packaging Removed macOS build steps from the release workflow and updated Windows packaging step. --- .github/workflows/release.yml | 96 ++--------------------------------- 1 file changed, 3 insertions(+), 93 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 733dc9f0..ab2ec0dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -151,96 +151,6 @@ jobs: overwrite: true prerelease: true - # ================================= - # macOS Build (darwin) - # ================================= - build-macos: - name: Build for macOS - permissions: - contents: write - strategy: - matrix: - include: - - arch: amd64 - runner: macos-13 - - arch: arm64 - runner: macos-14 - runs-on: ${{ matrix.runner }} - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Setup Go - uses: actions/setup-go@v6 - with: - go-version-file: go.mod - check-latest: true - - - name: Build 3X-UI for macOS (CGO) - shell: bash - run: | - set -euo pipefail - export CGO_ENABLED=1 - export GOOS=darwin - export GOARCH=${{ matrix.arch }} - - go version - go env GOOS GOARCH CGO_ENABLED - - go build -ldflags "-w -s" -o xui-release -v main.go - file xui-release - - mkdir -p x-ui/bin - cp xui-release x-ui/x-ui - cp x-ui.sh x-ui/ - - # Download dependencies - cd x-ui/bin - Xray_URL="https://github.com/XTLS/Xray-core/releases/download/v26.1.18/" - if [ "${{ matrix.arch }}" = "amd64" ]; then - curl -fsSL -o Xray-macos-64.zip "${Xray_URL}Xray-macos-64.zip" - unzip -q Xray-macos-64.zip - rm -f Xray-macos-64.zip - elif [ "${{ matrix.arch }}" = "arm64" ]; then - curl -fsSL -o Xray-macos-arm64-v8a.zip "${Xray_URL}Xray-macos-arm64-v8a.zip" - unzip -q Xray-macos-arm64-v8a.zip - rm -f Xray-macos-arm64-v8a.zip - fi - - rm -f geoip.dat geosite.dat - curl -fsSL -o geoip.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat - curl -fsSL -o geosite.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat - curl -fsSL -o geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat - curl -fsSL -o geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat - curl -fsSL -o geoip_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat - curl -fsSL -o geosite_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat - - mv xray xray-macos-${{ matrix.arch }} - cd ../.. - - - name: Package - shell: bash - run: tar -zcvf x-ui-darwin-${{ matrix.arch }}.tar.gz x-ui - - - name: Upload files to Artifacts - uses: actions/upload-artifact@v4 - with: - name: x-ui-darwin-${{ matrix.arch }} - path: ./x-ui-darwin-${{ matrix.arch }}.tar.gz - - - name: Upload files to GH release - uses: svenstaro/upload-release-action@v2 - if: | - (github.event_name == 'release' && github.event.action == 'published') || - (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ github.ref }} - file: x-ui-darwin-${{ matrix.arch }}.tar.gz - asset_name: x-ui-darwin-${{ matrix.arch }}.tar.gz - overwrite: true - prerelease: true - # ================================= # Windows Build # ================================= @@ -289,11 +199,11 @@ jobs: go build -ldflags "-w -s" -o xui-release.exe -v main.go - - name: Build 3X-UI for Windows + - name: Package 3X-UI for Windows shell: pwsh - run: | + run: | mkdir x-ui - Copy-Item xui-release.exe x-ui\ + Copy-Item xui-release.exe x-ui\x-ui.exe mkdir x-ui\bin cd x-ui\bin From e28dfd58fa32fed75d9e88ec43929c28716004ef Mon Sep 17 00:00:00 2001 From: Ebrahim Tahernejad Date: Sun, 1 Feb 2026 13:11:21 +0330 Subject: [PATCH 4/4] Rename step to copy and download resources --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ab2ec0dc..a4d726b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -199,7 +199,7 @@ jobs: go build -ldflags "-w -s" -o xui-release.exe -v main.go - - name: Package 3X-UI for Windows + - name: Copy and download resources shell: pwsh run: | mkdir x-ui