release.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. on:
  2. push:
  3. tags:
  4. - 'v[0-9]+.[0-9]+.[0-9]*'
  5. name: Create release and upload binaries
  6. jobs:
  7. build-linux:
  8. name: Build Linux All
  9. runs-on: ubuntu-latest
  10. steps:
  11. - name: Set up Go 1.16
  12. uses: actions/setup-go@v1
  13. with:
  14. go-version: 1.16
  15. - name: Checkout code
  16. uses: actions/checkout@v2
  17. - name: Build
  18. run: |
  19. make BUILD_NUMBER="${GITHUB_REF#refs/tags/v}" release-linux release-freebsd
  20. mkdir release
  21. mv build/*.tar.gz release
  22. - name: Upload artifacts
  23. uses: actions/upload-artifact@v1
  24. with:
  25. name: linux-latest
  26. path: release
  27. build-windows:
  28. name: Build Windows amd64
  29. runs-on: windows-latest
  30. steps:
  31. - name: Set up Go 1.16
  32. uses: actions/setup-go@v1
  33. with:
  34. go-version: 1.16
  35. - name: Checkout code
  36. uses: actions/checkout@v2
  37. - name: Build
  38. run: |
  39. echo $Env:GITHUB_REF.Substring(11)
  40. go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\nebula.exe ./cmd/nebula-service
  41. go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\nebula-cert.exe ./cmd/nebula-cert
  42. - name: Upload artifacts
  43. uses: actions/upload-artifact@v1
  44. with:
  45. name: windows-latest
  46. path: build
  47. build-darwin:
  48. name: Build Darwin amd64
  49. runs-on: macOS-latest
  50. steps:
  51. - name: Set up Go 1.16
  52. uses: actions/setup-go@v1
  53. with:
  54. go-version: 1.16
  55. - name: Checkout code
  56. uses: actions/checkout@v2
  57. - name: Build
  58. run: |
  59. make BUILD_NUMBER="${GITHUB_REF#refs/tags/v}" service build/nebula-darwin-amd64.tar.gz
  60. make BUILD_NUMBER="${GITHUB_REF#refs/tags/v}" service build/nebula-darwin-arm64.tar.gz
  61. mkdir release
  62. mv build/*.tar.gz release
  63. - name: Upload artifacts
  64. uses: actions/upload-artifact@v1
  65. with:
  66. name: darwin-latest
  67. path: release
  68. release:
  69. name: Create and Upload Release
  70. needs: [build-linux, build-darwin, build-windows]
  71. runs-on: ubuntu-latest
  72. steps:
  73. - name: Download Linux artifacts
  74. uses: actions/download-artifact@v1
  75. with:
  76. name: linux-latest
  77. - name: Download Darwin artifacts
  78. uses: actions/download-artifact@v1
  79. with:
  80. name: darwin-latest
  81. - name: Download Windows artifacts
  82. uses: actions/download-artifact@v1
  83. with:
  84. name: windows-latest
  85. - name: Zip Windows
  86. run: |
  87. cd windows-latest
  88. zip nebula-windows-amd64.zip nebula.exe nebula-cert.exe
  89. - name: Create sha256sum
  90. run: |
  91. for dir in linux-latest darwin-latest windows-latest
  92. do
  93. (
  94. cd $dir
  95. if [ "$dir" = windows-latest ]
  96. then
  97. sha256sum <nebula.exe | sed 's=-$=nebula-windows-amd64.zip/nebula.exe='
  98. sha256sum <nebula-cert.exe | sed 's=-$=nebula-windows-amd64.zip/nebula-cert.exe='
  99. sha256sum nebula-windows-amd64.zip
  100. else
  101. for v in *.tar.gz
  102. do
  103. sha256sum $v
  104. tar zxf $v --to-command='sh -c "sha256sum | sed s=-$='$v'/$TAR_FILENAME="'
  105. done
  106. fi
  107. )
  108. done | sort -k 2 >SHASUM256.txt
  109. - name: Create Release
  110. id: create_release
  111. uses: actions/create-release@v1
  112. env:
  113. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  114. with:
  115. tag_name: ${{ github.ref }}
  116. release_name: Release ${{ github.ref }}
  117. draft: false
  118. prerelease: false
  119. ##
  120. ## Upload assets (I wish we could just upload the whole folder at once...
  121. ##
  122. - name: Upload SHASUM256.txt
  123. uses: actions/[email protected]
  124. env:
  125. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  126. with:
  127. upload_url: ${{ steps.create_release.outputs.upload_url }}
  128. asset_path: ./SHASUM256.txt
  129. asset_name: SHASUM256.txt
  130. asset_content_type: text/plain
  131. - name: Upload darwin-amd64
  132. uses: actions/[email protected]
  133. env:
  134. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  135. with:
  136. upload_url: ${{ steps.create_release.outputs.upload_url }}
  137. asset_path: ./darwin-latest/nebula-darwin-amd64.tar.gz
  138. asset_name: nebula-darwin-amd64.tar.gz
  139. asset_content_type: application/gzip
  140. - name: Upload darwin-arm64
  141. uses: actions/[email protected]
  142. env:
  143. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  144. with:
  145. upload_url: ${{ steps.create_release.outputs.upload_url }}
  146. asset_path: ./darwin-latest/nebula-darwin-arm64.tar.gz
  147. asset_name: nebula-darwin-arm64.tar.gz
  148. asset_content_type: application/gzip
  149. - name: Upload windows-amd64
  150. uses: actions/[email protected]
  151. env:
  152. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  153. with:
  154. upload_url: ${{ steps.create_release.outputs.upload_url }}
  155. asset_path: ./windows-latest/nebula-windows-amd64.zip
  156. asset_name: nebula-windows-amd64.zip
  157. asset_content_type: application/zip
  158. - name: Upload linux-amd64
  159. uses: actions/[email protected]
  160. env:
  161. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  162. with:
  163. upload_url: ${{ steps.create_release.outputs.upload_url }}
  164. asset_path: ./linux-latest/nebula-linux-amd64.tar.gz
  165. asset_name: nebula-linux-amd64.tar.gz
  166. asset_content_type: application/gzip
  167. - name: Upload linux-386
  168. uses: actions/[email protected]
  169. env:
  170. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  171. with:
  172. upload_url: ${{ steps.create_release.outputs.upload_url }}
  173. asset_path: ./linux-latest/nebula-linux-386.tar.gz
  174. asset_name: nebula-linux-386.tar.gz
  175. asset_content_type: application/gzip
  176. - name: Upload linux-ppc64le
  177. uses: actions/[email protected]
  178. env:
  179. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  180. with:
  181. upload_url: ${{ steps.create_release.outputs.upload_url }}
  182. asset_path: ./linux-latest/nebula-linux-ppc64le.tar.gz
  183. asset_name: nebula-linux-ppc64le.tar.gz
  184. asset_content_type: application/gzip
  185. - name: Upload linux-arm-5
  186. uses: actions/[email protected]
  187. env:
  188. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  189. with:
  190. upload_url: ${{ steps.create_release.outputs.upload_url }}
  191. asset_path: ./linux-latest/nebula-linux-arm-5.tar.gz
  192. asset_name: nebula-linux-arm-5.tar.gz
  193. asset_content_type: application/gzip
  194. - name: Upload linux-arm-6
  195. uses: actions/[email protected]
  196. env:
  197. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  198. with:
  199. upload_url: ${{ steps.create_release.outputs.upload_url }}
  200. asset_path: ./linux-latest/nebula-linux-arm-6.tar.gz
  201. asset_name: nebula-linux-arm-6.tar.gz
  202. asset_content_type: application/gzip
  203. - name: Upload linux-arm-7
  204. uses: actions/[email protected]
  205. env:
  206. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  207. with:
  208. upload_url: ${{ steps.create_release.outputs.upload_url }}
  209. asset_path: ./linux-latest/nebula-linux-arm-7.tar.gz
  210. asset_name: nebula-linux-arm-7.tar.gz
  211. asset_content_type: application/gzip
  212. - name: Upload linux-arm64
  213. uses: actions/[email protected]
  214. env:
  215. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  216. with:
  217. upload_url: ${{ steps.create_release.outputs.upload_url }}
  218. asset_path: ./linux-latest/nebula-linux-arm64.tar.gz
  219. asset_name: nebula-linux-arm64.tar.gz
  220. asset_content_type: application/gzip
  221. - name: Upload linux-mips
  222. uses: actions/[email protected]
  223. env:
  224. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  225. with:
  226. upload_url: ${{ steps.create_release.outputs.upload_url }}
  227. asset_path: ./linux-latest/nebula-linux-mips.tar.gz
  228. asset_name: nebula-linux-mips.tar.gz
  229. asset_content_type: application/gzip
  230. - name: Upload linux-mipsle
  231. uses: actions/[email protected]
  232. env:
  233. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  234. with:
  235. upload_url: ${{ steps.create_release.outputs.upload_url }}
  236. asset_path: ./linux-latest/nebula-linux-mipsle.tar.gz
  237. asset_name: nebula-linux-mipsle.tar.gz
  238. asset_content_type: application/gzip
  239. - name: Upload linux-mips64
  240. uses: actions/[email protected]
  241. env:
  242. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  243. with:
  244. upload_url: ${{ steps.create_release.outputs.upload_url }}
  245. asset_path: ./linux-latest/nebula-linux-mips64.tar.gz
  246. asset_name: nebula-linux-mips64.tar.gz
  247. asset_content_type: application/gzip
  248. - name: Upload linux-mips64le
  249. uses: actions/[email protected]
  250. env:
  251. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  252. with:
  253. upload_url: ${{ steps.create_release.outputs.upload_url }}
  254. asset_path: ./linux-latest/nebula-linux-mips64le.tar.gz
  255. asset_name: nebula-linux-mips64le.tar.gz
  256. asset_content_type: application/gzip
  257. - name: Upload linux-mips-softfloat
  258. uses: actions/[email protected]
  259. env:
  260. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  261. with:
  262. upload_url: ${{ steps.create_release.outputs.upload_url }}
  263. asset_path: ./linux-latest/nebula-linux-mips-softfloat.tar.gz
  264. asset_name: nebula-linux-mips-softfloat.tar.gz
  265. asset_content_type: application/gzip
  266. - name: Upload freebsd-amd64
  267. uses: actions/[email protected]
  268. env:
  269. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  270. with:
  271. upload_url: ${{ steps.create_release.outputs.upload_url }}
  272. asset_path: ./linux-latest/nebula-freebsd-amd64.tar.gz
  273. asset_name: nebula-freebsd-amd64.tar.gz
  274. asset_content_type: application/gzip