release.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. name: Release 3X-UI
  2. on:
  3. workflow_dispatch:
  4. release:
  5. types: [published]
  6. push:
  7. branches:
  8. - main
  9. paths:
  10. - '**.js'
  11. - '**.css'
  12. - '**.html'
  13. - '**.sh'
  14. - '**.go'
  15. - 'go.mod'
  16. - 'go.sum'
  17. - 'x-ui.service'
  18. jobs:
  19. build:
  20. permissions:
  21. contents: write
  22. strategy:
  23. matrix:
  24. platform:
  25. - amd64
  26. - arm64
  27. - armv7
  28. - armv6
  29. - 386
  30. - armv5
  31. - s390x
  32. runs-on: ubuntu-22.04
  33. steps:
  34. - name: Checkout repository
  35. uses: actions/checkout@v4
  36. - name: Setup Go
  37. uses: actions/setup-go@v5
  38. with:
  39. go-version-file: go.mod
  40. check-latest: true
  41. - name: Install dependencies
  42. run: |
  43. sudo apt-get update
  44. if [ "${{ matrix.platform }}" == "arm64" ]; then
  45. sudo apt install gcc-aarch64-linux-gnu
  46. elif [ "${{ matrix.platform }}" == "armv7" ]; then
  47. sudo apt install gcc-arm-linux-gnueabihf
  48. elif [ "${{ matrix.platform }}" == "armv6" ]; then
  49. sudo apt install gcc-arm-linux-gnueabihf
  50. elif [ "${{ matrix.platform }}" == "386" ]; then
  51. sudo apt install gcc-i686-linux-gnu
  52. elif [ "${{ matrix.platform }}" == "armv5" ]; then
  53. sudo apt install gcc-arm-linux-gnueabi
  54. elif [ "${{ matrix.platform }}" == "s390x" ]; then
  55. sudo apt install gcc-s390x-linux-gnu
  56. fi
  57. - name: Build 3x-ui
  58. run: |
  59. export CGO_ENABLED=1
  60. export GOOS=linux
  61. export GOARCH=${{ matrix.platform }}
  62. if [ "${{ matrix.platform }}" == "arm64" ]; then
  63. export GOARCH=arm64
  64. export CC=aarch64-linux-gnu-gcc
  65. elif [ "${{ matrix.platform }}" == "armv7" ]; then
  66. export GOARCH=arm
  67. export GOARM=7
  68. export CC=arm-linux-gnueabihf-gcc
  69. elif [ "${{ matrix.platform }}" == "armv6" ]; then
  70. export GOARCH=arm
  71. export GOARM=6
  72. export CC=arm-linux-gnueabihf-gcc
  73. elif [ "${{ matrix.platform }}" == "386" ]; then
  74. export GOARCH=386
  75. export CC=i686-linux-gnu-gcc
  76. elif [ "${{ matrix.platform }}" == "armv5" ]; then
  77. export GOARCH=arm
  78. export GOARM=5
  79. export CC=arm-linux-gnueabi-gcc
  80. elif [ "${{ matrix.platform }}" == "s390x" ]; then
  81. export GOARCH=s390x
  82. export CC=s390x-linux-gnu-gcc
  83. fi
  84. go build -ldflags "-w -s" -o xui-release -v main.go
  85. mkdir x-ui
  86. cp xui-release x-ui/
  87. cp x-ui.service x-ui/
  88. cp x-ui.sh x-ui/
  89. mv x-ui/xui-release x-ui/x-ui
  90. mkdir x-ui/bin
  91. cd x-ui/bin
  92. # Download dependencies
  93. Xray_URL="https://github.com/XTLS/Xray-core/releases/download/v25.5.16/"
  94. if [ "${{ matrix.platform }}" == "amd64" ]; then
  95. wget -q ${Xray_URL}Xray-linux-64.zip
  96. unzip Xray-linux-64.zip
  97. rm -f Xray-linux-64.zip
  98. elif [ "${{ matrix.platform }}" == "arm64" ]; then
  99. wget -q ${Xray_URL}Xray-linux-arm64-v8a.zip
  100. unzip Xray-linux-arm64-v8a.zip
  101. rm -f Xray-linux-arm64-v8a.zip
  102. elif [ "${{ matrix.platform }}" == "armv7" ]; then
  103. wget -q ${Xray_URL}Xray-linux-arm32-v7a.zip
  104. unzip Xray-linux-arm32-v7a.zip
  105. rm -f Xray-linux-arm32-v7a.zip
  106. elif [ "${{ matrix.platform }}" == "armv6" ]; then
  107. wget -q ${Xray_URL}Xray-linux-arm32-v6.zip
  108. unzip Xray-linux-arm32-v6.zip
  109. rm -f Xray-linux-arm32-v6.zip
  110. elif [ "${{ matrix.platform }}" == "386" ]; then
  111. wget -q ${Xray_URL}Xray-linux-32.zip
  112. unzip Xray-linux-32.zip
  113. rm -f Xray-linux-32.zip
  114. elif [ "${{ matrix.platform }}" == "armv5" ]; then
  115. wget -q ${Xray_URL}Xray-linux-arm32-v5.zip
  116. unzip Xray-linux-arm32-v5.zip
  117. rm -f Xray-linux-arm32-v5.zip
  118. elif [ "${{ matrix.platform }}" == "s390x" ]; then
  119. wget -q ${Xray_URL}Xray-linux-s390x.zip
  120. unzip Xray-linux-s390x.zip
  121. rm -f Xray-linux-s390x.zip
  122. fi
  123. rm -f geoip.dat geosite.dat
  124. wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
  125. wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
  126. wget -q -O geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat
  127. wget -q -O geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat
  128. wget -q -O geoip_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat
  129. wget -q -O geosite_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat
  130. mv xray xray-linux-${{ matrix.platform }}
  131. cd ../..
  132. - name: Package
  133. run: tar -zcvf x-ui-linux-${{ matrix.platform }}.tar.gz x-ui
  134. - name: Upload files to Artifacts
  135. uses: actions/upload-artifact@v4
  136. with:
  137. name: x-ui-linux-${{ matrix.platform }}
  138. path: ./x-ui-linux-${{ matrix.platform }}.tar.gz
  139. - name: Upload files to GH release
  140. uses: svenstaro/upload-release-action@v2
  141. if: github.event_name == 'release' && github.event.action == 'published'
  142. with:
  143. repo_token: ${{ secrets.GITHUB_TOKEN }}
  144. tag: ${{ github.ref }}
  145. file: x-ui-linux-${{ matrix.platform }}.tar.gz
  146. asset_name: x-ui-linux-${{ matrix.platform }}.tar.gz
  147. prerelease: true