release.yml 7.0 KB

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