release.yml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. - goos: windows
  59. goarch: arm64
  60. # BEGIN MIPS
  61. - goos: linux
  62. goarch: mips64
  63. - goos: linux
  64. goarch: mips64le
  65. - goos: linux
  66. goarch: mipsle
  67. - goos: linux
  68. goarch: mips
  69. # END MIPS
  70. # BEGIN Android
  71. - goos: android
  72. goarch: arm64
  73. # END Android
  74. # END Other architectures
  75. fail-fast: false
  76. runs-on: ubuntu-latest
  77. env:
  78. GOOS: ${{ matrix.goos }}
  79. GOARCH: ${{ matrix.goarch }}
  80. GOARM: ${{ matrix.goarm }}
  81. CGO_ENABLED: 0
  82. steps:
  83. - name: Checkout codebase
  84. uses: actions/checkout@v2
  85. with:
  86. fetch-depth: 0
  87. - name: Show workflow information
  88. id: get_filename
  89. run: |
  90. export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM\"].friendlyName" -r < release/friendly-filenames.json)
  91. echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, RELEASE_NAME: $_NAME"
  92. echo "::set-output name=ASSET_NAME::$_NAME"
  93. echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
  94. - name: Set up Go
  95. uses: actions/setup-go@v2
  96. with:
  97. go-version: ^1.17
  98. - name: Get project dependencies
  99. run: go mod download
  100. - name: Build V2Ray
  101. run: |
  102. mkdir -p build_assets
  103. go build -v -o build_assets/v2ray -trimpath -ldflags "-s -w -buildid=" ./main
  104. - name: Download geo files
  105. run: |
  106. wget -O release/config/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat"
  107. wget -O release/config/geoip-only-cn-private.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip-only-cn-private.dat"
  108. wget -O release/config/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat"
  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.17
  150. - uses: actions/download-artifact@v2
  151. with:
  152. path: build_artifacts
  153. - name: Create extra package
  154. run: |
  155. pushd ./release/extra/
  156. zip -9vr ../../build_artifacts/v2ray-extra.zip .
  157. popd
  158. - name: Generate shasum
  159. run: |
  160. go get -v github.com/v2fly/V2BuildAssist/v2buildutil
  161. cd build_artifacts || exit 1
  162. mkdir .temp
  163. mv ./*/*.zip ./.temp
  164. rmdir ./*/
  165. mv ./.temp/* .
  166. ls -lah --recursive
  167. {
  168. go run github.com/v2fly/V2BuildAssist/v2buildutil gen version $(git describe --tags $(git rev-list --tags --max-count=1))
  169. go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2fly"
  170. for zip in $(ls *.zip); do
  171. go run github.com/v2fly/V2BuildAssist/v2buildutil gen file ${zip}
  172. done
  173. } >Release.unsigned.unsorted
  174. go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort < Release.unsigned.unsorted > Release.unsigned
  175. rm -f Release.unsigned.unsorted
  176. FILE=./Release.unsigned
  177. DGST=$FILE.dgst
  178. openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST
  179. openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST
  180. openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
  181. openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST
  182. - uses: actions/upload-artifact@v2
  183. with:
  184. name: Release.unsigned
  185. path: build_artifacts/Release.unsigned
  186. - uses: actions/upload-artifact@v2
  187. with:
  188. name: Release.unsigned.dgst
  189. path: build_artifacts/Release.unsigned.dgst
  190. - uses: actions/upload-artifact@v2
  191. with:
  192. name: v2ray-extra.zip
  193. path: build_artifacts/v2ray-extra.zip
  194. - name: Upload Release.unsigned related files
  195. uses: svenstaro/upload-release-action@v2
  196. if: github.event_name == 'release'
  197. with:
  198. repo_token: ${{ secrets.GITHUB_TOKEN }}
  199. file_glob: true
  200. file: build_artifacts/Release.unsigned*
  201. tag: ${{ github.ref }}
  202. - name: Upload extra package
  203. uses: svenstaro/upload-release-action@v2
  204. if: github.event_name == 'release'
  205. with:
  206. repo_token: ${{ secrets.GITHUB_TOKEN }}
  207. file_glob: true
  208. file: build_artifacts/v2ray-extra.zip
  209. tag: ${{ github.ref }}