fix build for windows
This commit is contained in:
+102
-40
@@ -17,21 +17,91 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-windows:
|
build-windows:
|
||||||
strategy:
|
runs-on: windows-latest
|
||||||
matrix:
|
steps:
|
||||||
platform:
|
- name: Checkout repository
|
||||||
- amd64
|
uses: actions/checkout@v5.0.0
|
||||||
- arm64
|
with:
|
||||||
include:
|
submodules: recursive
|
||||||
- platform: amd64
|
fetch-depth: 0
|
||||||
goarch: amd64
|
|
||||||
suffix: ""
|
|
||||||
- platform: arm64
|
|
||||||
goarch: arm64
|
|
||||||
suffix: "-arm64"
|
|
||||||
|
|
||||||
|
- 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: Install zip for Windows
|
||||||
|
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 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=amd64
|
||||||
|
|
||||||
|
echo "Building for Windows amd64"
|
||||||
|
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-amd64.zip" s-ui-windows
|
||||||
|
|
||||||
|
- name: Upload files to Artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: s-ui-windows-amd64
|
||||||
|
path: ./s-ui-windows-amd64.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-amd64.zip
|
||||||
|
asset_name: s-ui-windows-amd64.zip
|
||||||
|
prerelease: true
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
|
build-windows-arm64:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v5.0.0
|
uses: actions/checkout@v5.0.0
|
||||||
@@ -60,50 +130,42 @@ jobs:
|
|||||||
mv frontend/dist web/html
|
mv frontend/dist web/html
|
||||||
rm -fr frontend
|
rm -fr frontend
|
||||||
|
|
||||||
- name: Build S-UI for Windows
|
- name: Build s-ui for ARM64
|
||||||
run: |
|
run: |
|
||||||
export CGO_ENABLED=1
|
export CGO_ENABLED=0
|
||||||
export GOOS=windows
|
export GOOS=windows
|
||||||
export GOARCH=${{ matrix.goarch }}
|
export GOARCH=arm64
|
||||||
|
|
||||||
# Install MinGW-w64 for Windows cross-compilation
|
echo "Building for Windows ARM64 (32-bit)"
|
||||||
sudo apt-get update
|
go version
|
||||||
sudo apt-get install -y mingw-w64
|
go env GOOS GOARCH
|
||||||
|
|
||||||
# Set CC based on architecture
|
### Build s-ui without CGO for ARM64
|
||||||
case "${{ matrix.goarch }}" in
|
go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o sui.exe main.go
|
||||||
amd64) export CC=x86_64-w64-mingw32-gcc ;;
|
file sui.exe
|
||||||
arm64) export CC=x86_64-w64-mingw32-gcc ;; # MinGW doesn't support ARM64 well, use x86_64
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "Using CC: $CC"
|
|
||||||
echo "GOOS: $GOOS, GOARCH: $GOARCH"
|
|
||||||
|
|
||||||
### Build s-ui for Windows
|
|
||||||
go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor" -o "sui${{ matrix.suffix }}.exe" main.go
|
|
||||||
file "sui${{ matrix.suffix }}.exe"
|
|
||||||
|
|
||||||
mkdir s-ui-windows
|
mkdir s-ui-windows
|
||||||
cp "sui${{ matrix.suffix }}.exe" s-ui-windows/sui.exe
|
cp sui.exe s-ui-windows/
|
||||||
cp -r windows/* s-ui-windows/
|
cp -r windows/* s-ui-windows/
|
||||||
|
|
||||||
- name: Package
|
- name: Package ARM64
|
||||||
run: zip -r "s-ui-windows-${{ matrix.platform }}.zip" s-ui-windows
|
run: |
|
||||||
|
zip -r "s-ui-windows-arm64.zip" s-ui-windows
|
||||||
|
|
||||||
- name: Upload files to Artifacts
|
- name: Upload ARM64 files to Artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: s-ui-windows-${{ matrix.platform }}
|
name: s-ui-windows-arm64
|
||||||
path: ./s-ui-windows-${{ matrix.platform }}.zip
|
path: ./s-ui-windows-arm64.zip
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
|
||||||
- name: Upload to Release
|
- name: Upload ARM64 to Release
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
if: github.event_name == 'release' && github.event.action == 'published'
|
if: github.event_name == 'release' && github.event.action == 'published'
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
tag: ${{ github.ref }}
|
tag: ${{ github.ref }}
|
||||||
file: s-ui-windows-${{ matrix.platform }}.zip
|
file: s-ui-windows-arm64.zip
|
||||||
asset_name: s-ui-windows-${{ matrix.platform }}.zip
|
asset_name: s-ui-windows-arm64.zip
|
||||||
prerelease: true
|
prerelease: true
|
||||||
overwrite: true
|
overwrite: true
|
||||||
|
|||||||
+6
-1
@@ -7,6 +7,7 @@ import (
|
|||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"s-ui/cmd/migration"
|
"s-ui/cmd/migration"
|
||||||
"s-ui/config"
|
"s-ui/config"
|
||||||
"s-ui/database/model"
|
"s-ui/database/model"
|
||||||
@@ -287,7 +288,11 @@ func SendSighup() error {
|
|||||||
// Send SIGHUP to the current process
|
// Send SIGHUP to the current process
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
err := process.Signal(syscall.SIGHUP)
|
if runtime.GOOS == "windows" {
|
||||||
|
err = process.Kill()
|
||||||
|
} else {
|
||||||
|
err = process.Signal(syscall.SIGHUP)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("send signal SIGHUP failed:", err)
|
logger.Error("send signal SIGHUP failed:", err)
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -2,6 +2,7 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"s-ui/logger"
|
"s-ui/logger"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@@ -17,7 +18,11 @@ func (s *PanelService) RestartPanel(delay time.Duration) error {
|
|||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(delay)
|
time.Sleep(delay)
|
||||||
err := p.Signal(syscall.SIGHUP)
|
if runtime.GOOS == "windows" {
|
||||||
|
err = p.Kill()
|
||||||
|
} else {
|
||||||
|
err = p.Signal(syscall.SIGHUP)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("send signal SIGHUP failed:", err)
|
logger.Error("send signal SIGHUP failed:", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package service
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"s-ui/config"
|
"s-ui/config"
|
||||||
"s-ui/database"
|
"s-ui/database"
|
||||||
"s-ui/database/model"
|
"s-ui/database/model"
|
||||||
@@ -245,6 +246,9 @@ func (s *SettingService) GetTimeLocation() (*time.Location, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
l = "Local"
|
||||||
|
}
|
||||||
location, err := time.LoadLocation(l)
|
location, err := time.LoadLocation(l)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
defaultLocation := defaultValueMap["timeLocation"]
|
defaultLocation := defaultValueMap["timeLocation"]
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ REM Check if WinSW is available
|
|||||||
set "WINSW_PATH=%INSTALL_DIR%\winsw.exe"
|
set "WINSW_PATH=%INSTALL_DIR%\winsw.exe"
|
||||||
if not exist "%WINSW_PATH%" (
|
if not exist "%WINSW_PATH%" (
|
||||||
echo Downloading WinSW...
|
echo Downloading WinSW...
|
||||||
powershell -Command "& {Invoke-WebRequest -Uri 'https://github.com/winsw/winsw/releases/download/v3.0.0/WinSW-x64.exe' -OutFile '%WINSW_PATH%'}"
|
powershell -Command "& {Invoke-WebRequest -Uri 'https://github.com/winsw/winsw/releases/download/v2.12.0/WinSW-x64.exe' -OutFile '%WINSW_PATH%'}"
|
||||||
if exist "%WINSW_PATH%" (
|
if exist "%WINSW_PATH%" (
|
||||||
echo WinSW downloaded successfully
|
echo WinSW downloaded successfully
|
||||||
) else (
|
) else (
|
||||||
@@ -52,9 +52,6 @@ if exist "%WINSW_PATH%" (
|
|||||||
copy "winsw.exe" "s-ui-service.exe" >nul
|
copy "winsw.exe" "s-ui-service.exe" >nul
|
||||||
copy "s-ui-windows.xml" "s-ui-service.xml" >nul
|
copy "s-ui-windows.xml" "s-ui-service.xml" >nul
|
||||||
|
|
||||||
REM Update XML with correct paths
|
|
||||||
powershell -Command "& {(Get-Content 's-ui-service.xml') -replace '%BASE%', '%INSTALL_DIR%' | Set-Content 's-ui-service.xml'}"
|
|
||||||
|
|
||||||
REM Install service
|
REM Install service
|
||||||
s-ui-service.exe install
|
s-ui-service.exe install
|
||||||
if %errorLevel% equ 0 (
|
if %errorLevel% equ 0 (
|
||||||
|
|||||||
Reference in New Issue
Block a user