release.yml 6.3 KB

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