Skip to content

fix build for windows #7

fix build for windows

fix build for windows #7

Workflow file for this run

name: Build S-UI for Windows
on:
workflow_dispatch:
release:
types: [published]
push:
branches:
- main
paths:
- '.github/workflows/windows.yml'
- 'frontend/**'
- '**.go'
- 'go.mod'
- 'go.sum'
- 'windows/**'
jobs:
build-windows:
strategy:
matrix:
platform:
- amd64
- arm64
- 386
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5.0.0
with:
submodules: recursive
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Build frontend
run: |
cd frontend
npm install
npm run build
cd ..
mv frontend/dist web/html
rm -fr frontend
- name: Install MinGW-w64
run: |
sudo apt-get update
sudo apt-get install -y mingw-w64
# For ARM64 and 386, we need additional packages
if [ "${{ matrix.platform }}" = "arm64" ]; then
sudo apt-get install -y gcc-mingw-w64-aarch64
elif [ "${{ matrix.platform }}" = "386" ]; then
sudo apt-get install -y gcc-mingw-w64-i686
fi
- name: Build s-ui
run: |
export CGO_ENABLED=1
export GOOS=windows
export GOARCH=${{ matrix.platform }}
# Set MinGW-w64 compiler based on architecture
case "${{ matrix.platform }}" in
amd64)
export CC=x86_64-w64-mingw32-gcc
export CXX=x86_64-w64-mingw32-g++
;;
arm64)
export CC=aarch64-w64-mingw32-gcc
export CXX=aarch64-w64-mingw32-g++
;;
386)
export CC=i686-w64-mingw32-gcc
export CXX=i686-w64-mingw32-g++
;;
esac
echo "Using MinGW-w64 compiler: $CC"
$CC --version
### Build s-ui
go build -ldflags="-w -s -linkmode external -extldflags '-static'" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui main.go
file sui
ldd sui || echo "Static binary confirmed"
mkdir s-ui-windows
cp sui s-ui-windows/sui.exe
cp -r windows/* s-ui-windows/
- name: Package
run: zip -r "s-ui-windows-${{ matrix.platform }}.zip" s-ui-windows
- name: Upload files to Artifacts
uses: actions/upload-artifact@v4
with:
name: s-ui-windows-${{ matrix.platform }}
path: ./s-ui-windows-${{ matrix.platform }}.zip
retention-days: 30
- name: Upload to Release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release' && github.event.action == 'published'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
file: s-ui-windows-${{ matrix.platform }}.zip
asset_name: s-ui-windows-${{ matrix.platform }}.zip
prerelease: true
overwrite: true