name: Build S-UI for Windows on: workflow_dispatch: release: types: [published] push: branches: - main tags: - "*" paths: - '.github/workflows/windows.yml' - 'frontend/**' - '**.go' - 'go.mod' - 'go.sum' - 'windows/**' env: NODE_VERSION: "25" TAGS: "with_quic,with_grpc,with_utls,with_acme,with_gvisor,with_naive_outbound,with_purego,badlinkname,tfogo_checklinkname0,with_tailscale" LIBCRONET_BASE_URL: "https://github.com/SagerNet/cronet-go/releases/latest/download" jobs: build-frontend: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v6.0.2 with: submodules: recursive fetch-depth: 1 - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: ${{ env.NODE_VERSION }} registry-url: 'https://registry.npmjs.org' - name: Build frontend run: | cd frontend npm install npm run build cd .. - name: Upload frontend artifact uses: actions/upload-artifact@v7 with: name: frontend-dist path: frontend/dist retention-days: 1 build-windows: needs: build-frontend name: build-windows-${{ matrix.arch }} strategy: fail-fast: false matrix: include: - { arch: amd64, runner: windows-latest, cgo: "1" } - { arch: arm64, runner: ubuntu-latest, cgo: "0" } runs-on: ${{ matrix.runner }} steps: - name: Checkout repository uses: actions/checkout@v6.0.2 - name: Download frontend artifact uses: actions/download-artifact@v8 with: name: frontend-dist path: web/html - name: Setup Go uses: actions/setup-go@v6 with: cache: false go-version-file: go.mod - name: Install zip for Windows if: matrix.arch == 'amd64' shell: powershell run: | # Install Chocolatey if not available if (!(Get-Command choco -ErrorAction SilentlyContinue)) { Set-ExecutionPolicy Bypass -Scope Process -Force [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) } # Install zip choco install zip -y - name: Build s-ui shell: bash run: | export CGO_ENABLED=${{ matrix.cgo }} export GOOS=windows export GOARCH=${{ matrix.arch }} echo "Building for Windows ${{ matrix.arch }}" go version go env GOOS GOARCH go build -ldflags="-w -s -checklinkname=0" -tags "${{ env.TAGS }}" -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: Download libcronet-go shell: bash run: | curl -qsL -o s-ui-windows/libcronet.dll ${{ env.LIBCRONET_BASE_URL }}/libcronet-windows-${{ matrix.arch }}.dll - name: Package shell: bash run: | zip -r "s-ui-windows-${{ matrix.arch }}.zip" s-ui-windows - name: Upload files to Artifacts uses: actions/upload-artifact@v7 with: name: s-ui-windows-${{ matrix.arch }} path: ./s-ui-windows-${{ matrix.arch }}.zip retention-days: 30 - name: Upload to 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: s-ui-windows-${{ matrix.arch }}.zip asset_name: s-ui-windows-${{ matrix.arch }}.zip prerelease: true overwrite: true