fix build for windows #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 has issues on Windows runner due to compiler incompatibility | |
| # - arm64 | |
| runs-on: windows-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 | |
| shell: bash | |
| run: | | |
| cd frontend | |
| npm install | |
| npm run build | |
| cd .. | |
| mv frontend/dist web/html | |
| rm -fr frontend | |
| - name: Build s-ui | |
| shell: bash | |
| run: | | |
| export CGO_ENABLED=1 | |
| export GOOS=windows | |
| export GOARCH=${{ matrix.platform }} | |
| echo "Building for Windows ${{ matrix.platform }}" | |
| go version | |
| ### Build s-ui | |
| go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui.exe main.go | |
| file sui.exe | |
| mkdir s-ui-windows | |
| cp sui.exe s-ui-windows/ | |
| cp -r windows/* s-ui-windows/ | |
| - name: Package | |
| shell: bash | |
| 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 | |
| build-windows-arm64: | |
| 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: Build s-ui for ARM64 | |
| run: | | |
| export CGO_ENABLED=0 | |
| export GOOS=windows | |
| export GOARCH=arm64 | |
| echo "Building for Windows ARM64 (32-bit)" | |
| go version | |
| go env GOOS GOARCH | |
| ### Build s-ui without CGO for ARM64 | |
| go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui.exe main.go | |
| file sui.exe | |
| mkdir s-ui-windows | |
| cp sui.exe s-ui-windows/ | |
| cp -r windows/* s-ui-windows/ | |
| - name: Package ARM64 | |
| run: | | |
| zip -r "s-ui-windows-arm64.zip" s-ui-windows | |
| - name: Upload ARM64 files to Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: s-ui-windows-arm64 | |
| path: ./s-ui-windows-arm64.zip | |
| retention-days: 30 | |
| - name: Upload ARM64 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-arm64.zip | |
| asset_name: s-ui-windows-arm64.zip | |
| prerelease: true | |
| overwrite: true |