release.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. - name: Rename Windows V2Ray
  105. if: matrix.goos == 'windows'
  106. run: |
  107. cd ./build_assets || exit 1
  108. mv v2ray v2ray.exe
  109. - name: Download geo files
  110. run: |
  111. wget -O release/config/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat"
  112. wget -O release/config/geoip-only-cn-private.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip-only-cn-private.dat"
  113. wget -O release/config/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat"
  114. - name: Prepare package
  115. run: cp -v ./release/config/*.* ./build_assets
  116. - name: Prepare package for Linux
  117. if: matrix.goos == 'linux'
  118. run: cp -rv ./release/config/systemd ./build_assets/
  119. - name: Create ZIP archive
  120. run: |
  121. pushd build_assets || exit 1
  122. zip -9vr ../v2ray-$ASSET_NAME.zip .
  123. popd || exit 1
  124. FILE=./v2ray-$ASSET_NAME.zip
  125. DGST=$FILE.dgst
  126. openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST
  127. openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST
  128. openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
  129. openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST
  130. - name: Upload ZIP file to Artifacts
  131. uses: actions/upload-artifact@v2
  132. with:
  133. name: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
  134. path: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
  135. - name: Upload files to GitHub release
  136. uses: svenstaro/upload-release-action@v2
  137. if: github.event_name == 'release'
  138. with:
  139. repo_token: ${{ secrets.GITHUB_TOKEN }}
  140. file_glob: true
  141. file: ./v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip*
  142. tag: ${{ github.ref }}
  143. signature:
  144. runs-on: ubuntu-latest
  145. needs: build
  146. steps:
  147. - name: Checkout codebase
  148. uses: actions/checkout@v2
  149. with:
  150. fetch-depth: 0
  151. - name: Set up Go
  152. uses: actions/setup-go@v2
  153. with:
  154. go-version: ^1.17
  155. - uses: actions/download-artifact@v2
  156. with:
  157. path: build_artifacts
  158. - name: Create extra package
  159. run: |
  160. pushd ./release/extra/
  161. zip -9vr ../../build_artifacts/v2ray-extra.zip .
  162. popd
  163. - name: Generate shasum
  164. run: |
  165. go get -v github.com/v2fly/V2BuildAssist/v2buildutil
  166. cd build_artifacts || exit 1
  167. mkdir .temp
  168. mv ./*/*.zip ./.temp
  169. rmdir ./*/
  170. mv ./.temp/* .
  171. ls -lah --recursive
  172. {
  173. go run github.com/v2fly/V2BuildAssist/v2buildutil gen version $(git describe --tags $(git rev-list --tags --max-count=1))
  174. go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2fly"
  175. for zip in $(ls *.zip); do
  176. go run github.com/v2fly/V2BuildAssist/v2buildutil gen file ${zip}
  177. done
  178. } >Release.unsigned.unsorted
  179. go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort < Release.unsigned.unsorted > Release.unsigned
  180. rm -f Release.unsigned.unsorted
  181. FILE=./Release.unsigned
  182. DGST=$FILE.dgst
  183. openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST
  184. openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST
  185. openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
  186. openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST
  187. - uses: actions/upload-artifact@v2
  188. with:
  189. name: Release.unsigned
  190. path: build_artifacts/Release.unsigned
  191. - uses: actions/upload-artifact@v2
  192. with:
  193. name: Release.unsigned.dgst
  194. path: build_artifacts/Release.unsigned.dgst
  195. - uses: actions/upload-artifact@v2
  196. with:
  197. name: v2ray-extra.zip
  198. path: build_artifacts/v2ray-extra.zip
  199. - name: Upload Release.unsigned related files
  200. uses: svenstaro/upload-release-action@v2
  201. if: github.event_name == 'release'
  202. with:
  203. repo_token: ${{ secrets.GITHUB_TOKEN }}
  204. file_glob: true
  205. file: build_artifacts/Release.unsigned*
  206. tag: ${{ github.ref }}
  207. - name: Upload extra package
  208. uses: svenstaro/upload-release-action@v2
  209. if: github.event_name == 'release'
  210. with:
  211. repo_token: ${{ secrets.GITHUB_TOKEN }}
  212. file_glob: true
  213. file: build_artifacts/v2ray-extra.zip
  214. tag: ${{ github.ref }}