release.yml 6.3 KB

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