release.yml 7.3 KB

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