Skip to content

Commit 2ce8913

Browse files
committed
fix build for windows
1 parent 7bc7468 commit 2ce8913

File tree

1 file changed

+101
-39
lines changed

1 file changed

+101
-39
lines changed

.github/workflows/windows.yml

Lines changed: 101 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,8 @@ on:
1616
- 'windows/**'
1717

1818
jobs:
19-
build-windows:
20-
strategy:
21-
matrix:
22-
platform:
23-
- amd64
24-
- arm64
25-
include:
26-
- platform: amd64
27-
goarch: amd64
28-
suffix: ""
29-
- platform: arm64
30-
goarch: arm64
31-
suffix: "-arm64"
32-
33-
runs-on: ubuntu-latest
34-
19+
build-windows:
20+
runs-on: windows-latest
3521
steps:
3622
- name: Checkout repository
3723
uses: actions/checkout@v5.0.0
@@ -51,7 +37,20 @@ jobs:
5137
node-version: '22'
5238
registry-url: 'https://registry.npmjs.org'
5339

40+
- name: Install zip for Windows
41+
shell: powershell
42+
run: |
43+
# Install Chocolatey if not available
44+
if (!(Get-Command choco -ErrorAction SilentlyContinue)) {
45+
Set-ExecutionPolicy Bypass -Scope Process -Force
46+
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
47+
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
48+
}
49+
# Install zip
50+
choco install zip -y
51+
5452
- name: Build frontend
53+
shell: bash
5554
run: |
5655
cd frontend
5756
npm install
@@ -60,41 +59,34 @@ jobs:
6059
mv frontend/dist web/html
6160
rm -fr frontend
6261
63-
- name: Build S-UI for Windows
62+
- name: Build s-ui
63+
shell: bash
6464
run: |
6565
export CGO_ENABLED=1
6666
export GOOS=windows
67-
export GOARCH=${{ matrix.goarch }}
68-
69-
# Install MinGW-w64 for Windows cross-compilation
70-
sudo apt-get update
71-
sudo apt-get install -y mingw-w64
67+
export GOARCH=amd64
7268
73-
# Set CC based on architecture
74-
case "${{ matrix.goarch }}" in
75-
amd64) export CC=x86_64-w64-mingw32-gcc ;;
76-
arm64) export CC=x86_64-w64-mingw32-gcc ;; # MinGW doesn't support ARM64 well, use x86_64
77-
esac
69+
echo "Building for Windows amd64"
70+
go version
7871
79-
echo "Using CC: $CC"
80-
echo "GOOS: $GOOS, GOARCH: $GOARCH"
81-
82-
### Build s-ui for Windows
83-
go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o "sui${{ matrix.suffix }}.exe" main.go
84-
file "sui${{ matrix.suffix }}.exe"
72+
### Build s-ui
73+
go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui.exe main.go
74+
file sui.exe
8575
8676
mkdir s-ui-windows
87-
cp "sui${{ matrix.suffix }}.exe" s-ui-windows/sui.exe
77+
cp sui.exe s-ui-windows/
8878
cp -r windows/* s-ui-windows/
8979
9080
- name: Package
91-
run: zip -r "s-ui-windows-${{ matrix.platform }}.zip" s-ui-windows
81+
shell: bash
82+
run: |
83+
zip -r "s-ui-windows-amd64.zip" s-ui-windows
9284
9385
- name: Upload files to Artifacts
9486
uses: actions/upload-artifact@v4
9587
with:
96-
name: s-ui-windows-${{ matrix.platform }}
97-
path: ./s-ui-windows-${{ matrix.platform }}.zip
88+
name: s-ui-windows-amd64
89+
path: ./s-ui-windows-amd64.zip
9890
retention-days: 30
9991

10092
- name: Upload to Release
@@ -103,7 +95,77 @@ jobs:
10395
with:
10496
repo_token: ${{ secrets.GITHUB_TOKEN }}
10597
tag: ${{ github.ref }}
106-
file: s-ui-windows-${{ matrix.platform }}.zip
107-
asset_name: s-ui-windows-${{ matrix.platform }}.zip
98+
file: s-ui-windows-amd64.zip
99+
asset_name: s-ui-windows-amd64.zip
100+
prerelease: true
101+
overwrite: true
102+
103+
build-windows-arm64:
104+
runs-on: ubuntu-latest
105+
steps:
106+
- name: Checkout repository
107+
uses: actions/checkout@v5.0.0
108+
with:
109+
submodules: recursive
110+
fetch-depth: 0
111+
112+
- name: Setup Go
113+
uses: actions/setup-go@v5
114+
with:
115+
cache: false
116+
go-version-file: go.mod
117+
118+
- name: Setup Node.js
119+
uses: actions/setup-node@v4
120+
with:
121+
node-version: '22'
122+
registry-url: 'https://registry.npmjs.org'
123+
124+
- name: Build frontend
125+
run: |
126+
cd frontend
127+
npm install
128+
npm run build
129+
cd ..
130+
mv frontend/dist web/html
131+
rm -fr frontend
132+
133+
- name: Build s-ui for ARM64
134+
run: |
135+
export CGO_ENABLED=0
136+
export GOOS=windows
137+
export GOARCH=arm64
138+
139+
echo "Building for Windows ARM64 (32-bit)"
140+
go version
141+
go env GOOS GOARCH
142+
143+
### Build s-ui without CGO for ARM64
144+
go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui.exe main.go
145+
file sui.exe
146+
147+
mkdir s-ui-windows
148+
cp sui.exe s-ui-windows/
149+
cp -r windows/* s-ui-windows/
150+
151+
- name: Package ARM64
152+
run: |
153+
zip -r "s-ui-windows-arm64.zip" s-ui-windows
154+
155+
- name: Upload ARM64 files to Artifacts
156+
uses: actions/upload-artifact@v4
157+
with:
158+
name: s-ui-windows-arm64
159+
path: ./s-ui-windows-arm64.zip
160+
retention-days: 30
161+
162+
- name: Upload ARM64 to Release
163+
uses: svenstaro/upload-release-action@v2
164+
if: github.event_name == 'release' && github.event.action == 'published'
165+
with:
166+
repo_token: ${{ secrets.GITHUB_TOKEN }}
167+
tag: ${{ github.ref }}
168+
file: s-ui-windows-arm64.zip
169+
asset_name: s-ui-windows-arm64.zip
108170
prerelease: true
109171
overwrite: true

0 commit comments

Comments
 (0)