Updated github workflow

This commit is contained in:
Michael S2pac 2026-01-16 11:52:13 +03:00
parent 244d6b8544
commit fc87e2117b

View file

@ -6,7 +6,7 @@ on:
types: [published] types: [published]
push: push:
branches: branches:
- main - test-branch
tags: tags:
- "v*.*.*" - "v*.*.*"
paths: paths:
@ -82,6 +82,7 @@ jobs:
cp x-ui.service.debian x-ui/ cp x-ui.service.debian x-ui/
cp x-ui.service.rhel x-ui/ cp x-ui.service.rhel x-ui/
cp x-ui.sh x-ui/ cp x-ui.sh x-ui/
cp -r lib x-ui/
mv x-ui/xui-release x-ui/x-ui mv x-ui/xui-release x-ui/x-ui
mkdir x-ui/bin mkdir x-ui/bin
cd x-ui/bin cd x-ui/bin
@ -152,75 +153,75 @@ jobs:
# ================================= # =================================
# Windows Build # Windows Build
# ================================= # =================================
build-windows: # build-windows:
name: Build for Windows # name: Build for Windows
permissions: # permissions:
contents: write # contents: write
strategy: # strategy:
matrix: # matrix:
platform: # platform:
- amd64 # - amd64
runs-on: windows-latest # runs-on: windows-latest
steps: # steps:
- name: Checkout repository # - name: Checkout repository
uses: actions/checkout@v5 # uses: actions/checkout@v5
#
- name: Setup Go # - name: Setup Go
uses: actions/setup-go@v6 # uses: actions/setup-go@v6
with: # with:
go-version-file: go.mod # go-version-file: go.mod
check-latest: true # check-latest: true
#
- name: Build 3X-UI for Windows # - name: Build 3X-UI for Windows
shell: pwsh # shell: pwsh
run: | # run: |
$env:CGO_ENABLED="1" # $env:CGO_ENABLED="1"
$env:GOOS="windows" # $env:GOOS="windows"
$env:GOARCH="amd64" # $env:GOARCH="amd64"
go build -ldflags "-w -s" -o xui-release.exe -v main.go # go build -ldflags "-w -s" -o xui-release.exe -v main.go
#
mkdir x-ui # mkdir x-ui
Copy-Item xui-release.exe x-ui\ # Copy-Item xui-release.exe x-ui\
mkdir x-ui\bin # mkdir x-ui\bin
cd x-ui\bin # cd x-ui\bin
#
# Download Xray for Windows # # Download Xray for Windows
$Xray_URL = "https://github.com/XTLS/Xray-core/releases/download/v25.12.8/" # $Xray_URL = "https://github.com/XTLS/Xray-core/releases/download/v25.12.8/"
Invoke-WebRequest -Uri "${Xray_URL}Xray-windows-64.zip" -OutFile "Xray-windows-64.zip" # Invoke-WebRequest -Uri "${Xray_URL}Xray-windows-64.zip" -OutFile "Xray-windows-64.zip"
Expand-Archive -Path "Xray-windows-64.zip" -DestinationPath . # Expand-Archive -Path "Xray-windows-64.zip" -DestinationPath .
Remove-Item "Xray-windows-64.zip" # Remove-Item "Xray-windows-64.zip"
Remove-Item geoip.dat, geosite.dat -ErrorAction SilentlyContinue # Remove-Item geoip.dat, geosite.dat -ErrorAction SilentlyContinue
Invoke-WebRequest -Uri "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat" -OutFile "geoip.dat" # Invoke-WebRequest -Uri "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat" -OutFile "geoip.dat"
Invoke-WebRequest -Uri "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" -OutFile "geosite.dat" # Invoke-WebRequest -Uri "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" -OutFile "geosite.dat"
Invoke-WebRequest -Uri "https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat" -OutFile "geoip_IR.dat" # Invoke-WebRequest -Uri "https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat" -OutFile "geoip_IR.dat"
Invoke-WebRequest -Uri "https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat" -OutFile "geosite_IR.dat" # Invoke-WebRequest -Uri "https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat" -OutFile "geosite_IR.dat"
Invoke-WebRequest -Uri "https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat" -OutFile "geoip_RU.dat" # Invoke-WebRequest -Uri "https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat" -OutFile "geoip_RU.dat"
Invoke-WebRequest -Uri "https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat" -OutFile "geosite_RU.dat" # Invoke-WebRequest -Uri "https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat" -OutFile "geosite_RU.dat"
Rename-Item xray.exe xray-windows-amd64.exe # Rename-Item xray.exe xray-windows-amd64.exe
cd .. # cd ..
Copy-Item -Path ..\windows_files\* -Destination . -Recurse # Copy-Item -Path ..\windows_files\* -Destination . -Recurse
cd .. # cd ..
#
- name: Package to Zip # - name: Package to Zip
shell: pwsh # shell: pwsh
run: | # run: |
Compress-Archive -Path .\x-ui -DestinationPath "x-ui-windows-amd64.zip" # Compress-Archive -Path .\x-ui -DestinationPath "x-ui-windows-amd64.zip"
#
- name: Upload files to Artifacts # - name: Upload files to Artifacts
uses: actions/upload-artifact@v4 # uses: actions/upload-artifact@v4
with: # with:
name: x-ui-windows-amd64 # name: x-ui-windows-amd64
path: ./x-ui-windows-amd64.zip # path: ./x-ui-windows-amd64.zip
#
- name: Upload files to GH release # - name: Upload files to GH release
uses: svenstaro/upload-release-action@v2 # uses: svenstaro/upload-release-action@v2
if: | # if: |
(github.event_name == 'release' && github.event.action == 'published') || # (github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) # (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
with: # with:
repo_token: ${{ secrets.GITHUB_TOKEN }} # repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }} # tag: ${{ github.ref }}
file: x-ui-windows-amd64.zip # file: x-ui-windows-amd64.zip
asset_name: x-ui-windows-amd64.zip # asset_name: x-ui-windows-amd64.zip
overwrite: true # overwrite: true
prerelease: true # prerelease: true