1
0

release.yml 5.7 KB

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