release.yml 6.4 KB

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