release.yml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. # BEGIN Windows ARM 7
  48. - goos: windows
  49. goarch: arm
  50. goarm: 7
  51. # END Windows ARM 7
  52. # BEGIN FreeBSD ARM 6 7
  53. - goos: freebsd
  54. goarch: arm
  55. goarm: 6
  56. - goos: freebsd
  57. goarch: arm
  58. goarm: 7
  59. # END FreeBSD ARM 6 7
  60. # BEGIN OpenBSD ARM 6 7
  61. - goos: openbsd
  62. goarch: arm
  63. goarm: 6
  64. - goos: openbsd
  65. goarch: arm
  66. goarm: 7
  67. # END OpenBSD ARM 6 7
  68. # BEGIN Other architectures
  69. - goos: darwin
  70. goarch: arm64
  71. - goos: linux
  72. goarch: arm64
  73. - goos: linux
  74. goarch: riscv64
  75. - goos: windows
  76. goarch: arm64
  77. - goos: android
  78. goarch: arm64
  79. - goos: freebsd
  80. goarch: arm64
  81. - goos: openbsd
  82. goarch: arm64
  83. # BEGIN MIPS
  84. - goos: linux
  85. goarch: mips64
  86. - goos: linux
  87. goarch: mips64le
  88. - goos: linux
  89. goarch: mipsle
  90. - goos: linux
  91. goarch: mips
  92. # END MIPS
  93. # END Other architectures
  94. fail-fast: false
  95. runs-on: ubuntu-latest
  96. env:
  97. GOOS: ${{ matrix.goos }}
  98. GOARCH: ${{ matrix.goarch }}
  99. GOARM: ${{ matrix.goarm }}
  100. CGO_ENABLED: 0
  101. steps:
  102. - name: Checkout codebase
  103. uses: actions/checkout@v3
  104. with:
  105. fetch-depth: 0
  106. - name: Show workflow information
  107. id: get_filename
  108. run: |
  109. export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM\"].friendlyName" -r < release/friendly-filenames.json)
  110. echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, RELEASE_NAME: $_NAME"
  111. echo "::set-output name=ASSET_NAME::$_NAME"
  112. echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
  113. - name: Set up Go
  114. uses: actions/setup-go@v3
  115. with:
  116. go-version: ^1.18
  117. - name: Get project dependencies
  118. run: go mod download
  119. - name: Build V2Ray
  120. run: |
  121. mkdir -p build_assets
  122. go build -v -o build_assets/v2ray -trimpath -ldflags "-s -w -buildid=" ./main
  123. - name: Rename Windows V2Ray
  124. if: matrix.goos == 'windows'
  125. run: |
  126. cd ./build_assets || exit 1
  127. mv v2ray v2ray.exe
  128. - name: Download geo files
  129. run: |
  130. wget -O release/config/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat"
  131. wget -O release/config/geoip-only-cn-private.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip-only-cn-private.dat"
  132. wget -O release/config/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat"
  133. - name: Prepare package
  134. run: cp -v ./release/config/*.* ./build_assets
  135. - name: Prepare package for Linux
  136. if: matrix.goos == 'linux'
  137. run: cp -rv ./release/config/systemd ./build_assets/
  138. - name: Create ZIP archive
  139. run: |
  140. pushd build_assets || exit 1
  141. zip -9vr ../v2ray-$ASSET_NAME.zip .
  142. popd || exit 1
  143. FILE=./v2ray-$ASSET_NAME.zip
  144. DGST=$FILE.dgst
  145. openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST
  146. openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST
  147. openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
  148. openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST
  149. - name: Upload ZIP file to Artifacts
  150. uses: actions/upload-artifact@v3
  151. with:
  152. name: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
  153. path: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
  154. - name: Upload files to GitHub release
  155. uses: svenstaro/upload-release-action@v2
  156. if: github.event_name == 'release'
  157. with:
  158. repo_token: ${{ secrets.GITHUB_TOKEN }}
  159. file_glob: true
  160. file: ./v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip*
  161. tag: ${{ github.ref }}
  162. signature:
  163. runs-on: ubuntu-latest
  164. needs: build
  165. steps:
  166. - name: Checkout codebase
  167. uses: actions/checkout@v3
  168. with:
  169. fetch-depth: 0
  170. - name: Set up Go
  171. uses: actions/setup-go@v3
  172. with:
  173. go-version: ^1.18
  174. - uses: actions/download-artifact@v3
  175. with:
  176. path: build_artifacts
  177. - name: Create extra package
  178. run: |
  179. pushd ./release/extra/
  180. zip -9vr ../../build_artifacts/v2ray-extra.zip .
  181. popd
  182. - name: Generate shasum
  183. run: |
  184. go get -v github.com/v2fly/V2BuildAssist/v2buildutil
  185. cd build_artifacts || exit 1
  186. mkdir .temp
  187. mv ./*/*.zip ./.temp
  188. rmdir ./*/
  189. mv ./.temp/* .
  190. ls -lah --recursive
  191. {
  192. go run github.com/v2fly/V2BuildAssist/v2buildutil gen version $(git describe --tags $(git rev-list --tags --max-count=1))
  193. go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2fly"
  194. for zip in $(ls *.zip); do
  195. go run github.com/v2fly/V2BuildAssist/v2buildutil gen file ${zip}
  196. done
  197. } >Release.unsigned.unsorted
  198. go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort < Release.unsigned.unsorted > Release.unsigned
  199. rm -f Release.unsigned.unsorted
  200. FILE=./Release.unsigned
  201. DGST=$FILE.dgst
  202. openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST
  203. openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST
  204. openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
  205. openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST
  206. - uses: actions/upload-artifact@v3
  207. with:
  208. name: Release.unsigned
  209. path: build_artifacts/Release.unsigned
  210. - uses: actions/upload-artifact@v3
  211. with:
  212. name: Release.unsigned.dgst
  213. path: build_artifacts/Release.unsigned.dgst
  214. - uses: actions/upload-artifact@v3
  215. with:
  216. name: v2ray-extra.zip
  217. path: build_artifacts/v2ray-extra.zip
  218. - name: Upload Release.unsigned related files
  219. uses: svenstaro/upload-release-action@v2
  220. if: github.event_name == 'release'
  221. with:
  222. repo_token: ${{ secrets.GITHUB_TOKEN }}
  223. file_glob: true
  224. file: build_artifacts/Release.unsigned*
  225. tag: ${{ github.ref }}
  226. - name: Upload extra package
  227. uses: svenstaro/upload-release-action@v2
  228. if: github.event_name == 'release'
  229. with:
  230. repo_token: ${{ secrets.GITHUB_TOKEN }}
  231. file_glob: true
  232. file: build_artifacts/v2ray-extra.zip
  233. tag: ${{ github.ref }}