release.yml 5.6 KB

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