release.yml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. name: Release
  2. on:
  3. release:
  4. types: [prereleased]
  5. push:
  6. branches:
  7. - master
  8. - v*
  9. - dev*
  10. paths:
  11. - "**/*.go"
  12. - "go.mod"
  13. - "go.sum"
  14. - ".github/workflows/*.yml"
  15. pull_request:
  16. types: [opened, synchronize, reopened]
  17. paths:
  18. - "**/*.go"
  19. - "go.mod"
  20. - "go.sum"
  21. - ".github/workflows/*.yml"
  22. jobs:
  23. build:
  24. strategy:
  25. matrix:
  26. # Include amd64 on all platforms.
  27. goos: [windows, freebsd, openbsd, linux, dragonfly, darwin]
  28. goarch: [amd64, 386]
  29. exclude:
  30. # Exclude i386 on darwin and dragonfly.
  31. - goarch: 386
  32. goos: dragonfly
  33. - goarch: 386
  34. goos: darwin
  35. include:
  36. # BEGIN Linux ARM 5 6 7
  37. - goos: linux
  38. goarch: arm
  39. goarm: 7
  40. - goos: linux
  41. goarch: arm
  42. goarm: 6
  43. - goos: linux
  44. goarch: arm
  45. goarm: 5
  46. # END Linux ARM 5 6 7
  47. # Windows ARM 7
  48. - goos: windows
  49. goarch: arm
  50. goarm: 7
  51. # BEGIN Other architectures
  52. - goos: darwin
  53. goarch: arm64
  54. - goos: linux
  55. goarch: arm64
  56. - goos: linux
  57. goarch: riscv64
  58. - goos: windows
  59. goarch: arm64
  60. # BEGIN MIPS
  61. - goos: linux
  62. goarch: mips64
  63. - goos: linux
  64. goarch: mips64le
  65. - goos: linux
  66. goarch: mipsle
  67. - goos: linux
  68. goarch: mips
  69. # END MIPS
  70. # BEGIN Android
  71. - goos: android
  72. goarch: arm64
  73. # END Android
  74. # END Other architectures
  75. fail-fast: false
  76. runs-on: ubuntu-latest
  77. env:
  78. GOOS: ${{ matrix.goos }}
  79. GOARCH: ${{ matrix.goarch }}
  80. GOARM: ${{ matrix.goarm }}
  81. CGO_ENABLED: 0
  82. steps:
  83. - name: Checkout codebase
  84. uses: actions/checkout@v2
  85. with:
  86. fetch-depth: 0
  87. - name: Show workflow information
  88. id: get_filename
  89. run: |
  90. export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM\"].friendlyName" -r < release/friendly-filenames.json)
  91. echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, RELEASE_NAME: $_NAME"
  92. echo "::set-output name=ASSET_NAME::$_NAME"
  93. echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
  94. - name: Set up Go
  95. uses: actions/setup-go@v2
  96. with:
  97. go-version: ^1.17
  98. - name: Get project dependencies
  99. run: go mod download
  100. - name: Build V2Ray
  101. run: |
  102. mkdir -p build_assets
  103. go build -v -o build_assets/v2ray -trimpath -ldflags "-s -w -buildid=" ./main
  104. go build -v -o build_assets/v2ctl -trimpath -ldflags "-s -w -buildid=" -tags confonly ./infra/control/main
  105. - name: Build Windows wv2ray
  106. if: matrix.goos == 'windows'
  107. run: |
  108. echo "::warning ::wv2ray.exe will be removed in v5"
  109. go build -v -o build_assets/wv2ray.exe -trimpath -ldflags "-s -w -H windowsgui -buildid=" ./main
  110. cd ./build_assets || exit 1
  111. mv v2ray v2ray.exe
  112. mv v2ctl v2ctl.exe
  113. - name: Download geo files
  114. run: |
  115. wget -O release/config/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat"
  116. wget -O release/config/geoip-only-cn-private.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip-only-cn-private.dat"
  117. wget -O release/config/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat"
  118. - name: Prepare package
  119. run: cp -v ./release/config/*.* ./build_assets
  120. - name: Prepare package for Linux
  121. if: matrix.goos == 'linux'
  122. run: cp -rv ./release/config/systemd ./build_assets/
  123. - name: Create ZIP archive
  124. run: |
  125. pushd build_assets || exit 1
  126. zip -9vr ../v2ray-$ASSET_NAME.zip .
  127. popd || exit 1
  128. FILE=./v2ray-$ASSET_NAME.zip
  129. DGST=$FILE.dgst
  130. openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST
  131. openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST
  132. openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
  133. openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST
  134. - name: Upload ZIP file to Artifacts
  135. uses: actions/upload-artifact@v2
  136. with:
  137. name: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
  138. path: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
  139. - name: Upload files to GitHub release
  140. uses: svenstaro/upload-release-action@v2
  141. if: github.event_name == 'release'
  142. with:
  143. repo_token: ${{ secrets.GITHUB_TOKEN }}
  144. file_glob: true
  145. file: ./v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip*
  146. tag: ${{ github.ref }}
  147. signature:
  148. runs-on: ubuntu-latest
  149. needs: build
  150. steps:
  151. - name: Checkout codebase
  152. uses: actions/checkout@v2
  153. with:
  154. fetch-depth: 0
  155. - name: Set up Go
  156. uses: actions/setup-go@v2
  157. with:
  158. go-version: ^1.17
  159. - uses: actions/download-artifact@v2
  160. with:
  161. path: build_artifacts
  162. - name: Create extra package
  163. run: |
  164. pushd ./release/extra/
  165. zip -9vr ../../build_artifacts/v2ray-extra.zip .
  166. popd
  167. - name: Generate shasum
  168. run: |
  169. go get -v github.com/v2fly/V2BuildAssist/v2buildutil
  170. cd build_artifacts || exit 1
  171. mkdir .temp
  172. mv ./*/*.zip ./.temp
  173. rmdir ./*/
  174. mv ./.temp/* .
  175. ls -lah --recursive
  176. {
  177. go run github.com/v2fly/V2BuildAssist/v2buildutil gen version $(git describe --tags $(git rev-list --tags --max-count=1))
  178. go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2fly"
  179. for zip in $(ls *.zip); do
  180. go run github.com/v2fly/V2BuildAssist/v2buildutil gen file ${zip}
  181. done
  182. } >Release.unsigned.unsorted
  183. go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort < Release.unsigned.unsorted > Release.unsigned
  184. rm -f Release.unsigned.unsorted
  185. FILE=./Release.unsigned
  186. DGST=$FILE.dgst
  187. openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST
  188. openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST
  189. openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
  190. openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST
  191. - uses: actions/upload-artifact@v2
  192. with:
  193. name: Release.unsigned
  194. path: build_artifacts/Release.unsigned
  195. - uses: actions/upload-artifact@v2
  196. with:
  197. name: Release.unsigned.dgst
  198. path: build_artifacts/Release.unsigned.dgst
  199. - uses: actions/upload-artifact@v2
  200. with:
  201. name: v2ray-extra.zip
  202. path: build_artifacts/v2ray-extra.zip
  203. - name: Upload Release.unsigned related files
  204. uses: svenstaro/upload-release-action@v2
  205. if: github.event_name == 'release'
  206. with:
  207. repo_token: ${{ secrets.GITHUB_TOKEN }}
  208. file_glob: true
  209. file: build_artifacts/Release.unsigned*
  210. tag: ${{ github.ref }}
  211. - name: Upload extra package
  212. uses: svenstaro/upload-release-action@v2
  213. if: github.event_name == 'release'
  214. with:
  215. repo_token: ${{ secrets.GITHUB_TOKEN }}
  216. file_glob: true
  217. file: build_artifacts/v2ray-extra.zip
  218. tag: ${{ github.ref }}