release.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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. - uses: actions/checkout@v3
  12. - uses: actions/setup-go@v4
  13. with:
  14. go-version-file: 'go.mod'
  15. check-latest: true
  16. - name: Build
  17. run: |
  18. make BUILD_NUMBER="${GITHUB_REF#refs/tags/v}" release-linux release-freebsd
  19. mkdir release
  20. mv build/*.tar.gz release
  21. - name: Upload artifacts
  22. uses: actions/upload-artifact@v2
  23. with:
  24. name: linux-latest
  25. path: release
  26. build-windows:
  27. name: Build Windows
  28. runs-on: windows-latest
  29. steps:
  30. - uses: actions/checkout@v3
  31. - uses: actions/setup-go@v4
  32. with:
  33. go-version-file: 'go.mod'
  34. check-latest: true
  35. - name: Build
  36. run: |
  37. echo $Env:GITHUB_REF.Substring(11)
  38. mkdir build\windows-amd64
  39. $Env:GOARCH = "amd64"
  40. go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\windows-amd64\nebula.exe ./cmd/nebula-service
  41. go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\windows-amd64\nebula-cert.exe ./cmd/nebula-cert
  42. mkdir build\windows-arm64
  43. $Env:GOARCH = "arm64"
  44. go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\windows-arm64\nebula.exe ./cmd/nebula-service
  45. go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\windows-arm64\nebula-cert.exe ./cmd/nebula-cert
  46. mkdir build\dist\windows
  47. mv dist\windows\wintun build\dist\windows\
  48. - name: Upload artifacts
  49. uses: actions/upload-artifact@v2
  50. with:
  51. name: windows-latest
  52. path: build
  53. build-darwin:
  54. name: Build Universal Darwin
  55. env:
  56. HAS_SIGNING_CREDS: ${{ secrets.AC_USERNAME != '' }}
  57. runs-on: macos-11
  58. steps:
  59. - uses: actions/checkout@v3
  60. - uses: actions/setup-go@v4
  61. with:
  62. go-version-file: 'go.mod'
  63. check-latest: true
  64. - name: Import certificates
  65. if: env.HAS_SIGNING_CREDS == 'true'
  66. uses: Apple-Actions/import-codesign-certs@v1
  67. with:
  68. p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
  69. p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
  70. - name: Build, sign, and notarize
  71. env:
  72. AC_USERNAME: ${{ secrets.AC_USERNAME }}
  73. AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
  74. run: |
  75. rm -rf release
  76. mkdir release
  77. make BUILD_NUMBER="${GITHUB_REF#refs/tags/v}" service build/darwin-amd64/nebula build/darwin-amd64/nebula-cert
  78. make BUILD_NUMBER="${GITHUB_REF#refs/tags/v}" service build/darwin-arm64/nebula build/darwin-arm64/nebula-cert
  79. lipo -create -output ./release/nebula ./build/darwin-amd64/nebula ./build/darwin-arm64/nebula
  80. lipo -create -output ./release/nebula-cert ./build/darwin-amd64/nebula-cert ./build/darwin-arm64/nebula-cert
  81. if [ -n "$AC_USERNAME" ]; then
  82. codesign -s "10BC1FDDEB6CE753550156C0669109FAC49E4D1E" -f -v --timestamp --options=runtime -i "net.defined.nebula" ./release/nebula
  83. codesign -s "10BC1FDDEB6CE753550156C0669109FAC49E4D1E" -f -v --timestamp --options=runtime -i "net.defined.nebula-cert" ./release/nebula-cert
  84. fi
  85. zip -j release/nebula-darwin.zip release/nebula-cert release/nebula
  86. if [ -n "$AC_USERNAME" ]; then
  87. xcrun notarytool submit ./release/nebula-darwin.zip --team-id "576H3XS7FP" --apple-id "$AC_USERNAME" --password "$AC_PASSWORD" --wait
  88. fi
  89. - name: Upload artifacts
  90. uses: actions/upload-artifact@v2
  91. with:
  92. name: darwin-latest
  93. path: ./release/*
  94. release:
  95. name: Create and Upload Release
  96. needs: [build-linux, build-darwin, build-windows]
  97. runs-on: ubuntu-latest
  98. steps:
  99. - name: Download artifacts
  100. uses: actions/download-artifact@v2
  101. - name: Zip Windows
  102. run: |
  103. cd windows-latest
  104. cp windows-amd64/* .
  105. zip -r nebula-windows-amd64.zip nebula.exe nebula-cert.exe dist
  106. cp windows-arm64/* .
  107. zip -r nebula-windows-arm64.zip nebula.exe nebula-cert.exe dist
  108. - name: Create sha256sum
  109. run: |
  110. for dir in linux-latest darwin-latest windows-latest
  111. do
  112. (
  113. cd $dir
  114. if [ "$dir" = windows-latest ]
  115. then
  116. sha256sum <windows-amd64/nebula.exe | sed 's=-$=nebula-windows-amd64.zip/nebula.exe='
  117. sha256sum <windows-amd64/nebula-cert.exe | sed 's=-$=nebula-windows-amd64.zip/nebula-cert.exe='
  118. sha256sum <windows-arm64/nebula.exe | sed 's=-$=nebula-windows-arm64.zip/nebula.exe='
  119. sha256sum <windows-arm64/nebula-cert.exe | sed 's=-$=nebula-windows-arm64.zip/nebula-cert.exe='
  120. sha256sum nebula-windows-amd64.zip
  121. sha256sum nebula-windows-arm64.zip
  122. elif [ "$dir" = darwin-latest ]
  123. then
  124. sha256sum <nebula-darwin.zip | sed 's=-$=nebula-darwin.zip='
  125. sha256sum <nebula | sed 's=-$=nebula-darwin.zip/nebula='
  126. sha256sum <nebula-cert | sed 's=-$=nebula-darwin.zip/nebula-cert='
  127. else
  128. for v in *.tar.gz
  129. do
  130. sha256sum $v
  131. tar zxf $v --to-command='sh -c "sha256sum | sed s=-$='$v'/$TAR_FILENAME="'
  132. done
  133. fi
  134. )
  135. done | sort -k 2 >SHASUM256.txt
  136. - name: Create Release
  137. id: create_release
  138. uses: actions/create-release@v1
  139. env:
  140. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  141. with:
  142. tag_name: ${{ github.ref }}
  143. release_name: Release ${{ github.ref }}
  144. draft: false
  145. prerelease: false
  146. ##
  147. ## Upload assets (I wish we could just upload the whole folder at once...
  148. ##
  149. - name: Upload SHASUM256.txt
  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: ./SHASUM256.txt
  156. asset_name: SHASUM256.txt
  157. asset_content_type: text/plain
  158. - name: Upload darwin zip
  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: ./darwin-latest/nebula-darwin.zip
  165. asset_name: nebula-darwin.zip
  166. asset_content_type: application/zip
  167. - name: Upload windows-amd64
  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: ./windows-latest/nebula-windows-amd64.zip
  174. asset_name: nebula-windows-amd64.zip
  175. asset_content_type: application/zip
  176. - name: Upload windows-arm64
  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: ./windows-latest/nebula-windows-arm64.zip
  183. asset_name: nebula-windows-arm64.zip
  184. asset_content_type: application/zip
  185. - name: Upload linux-amd64
  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-amd64.tar.gz
  192. asset_name: nebula-linux-amd64.tar.gz
  193. asset_content_type: application/gzip
  194. - name: Upload linux-386
  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-386.tar.gz
  201. asset_name: nebula-linux-386.tar.gz
  202. asset_content_type: application/gzip
  203. - name: Upload linux-ppc64le
  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-ppc64le.tar.gz
  210. asset_name: nebula-linux-ppc64le.tar.gz
  211. asset_content_type: application/gzip
  212. - name: Upload linux-arm-5
  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-arm-5.tar.gz
  219. asset_name: nebula-linux-arm-5.tar.gz
  220. asset_content_type: application/gzip
  221. - name: Upload linux-arm-6
  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-arm-6.tar.gz
  228. asset_name: nebula-linux-arm-6.tar.gz
  229. asset_content_type: application/gzip
  230. - name: Upload linux-arm-7
  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-arm-7.tar.gz
  237. asset_name: nebula-linux-arm-7.tar.gz
  238. asset_content_type: application/gzip
  239. - name: Upload linux-arm64
  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-arm64.tar.gz
  246. asset_name: nebula-linux-arm64.tar.gz
  247. asset_content_type: application/gzip
  248. - name: Upload linux-mips
  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-mips.tar.gz
  255. asset_name: nebula-linux-mips.tar.gz
  256. asset_content_type: application/gzip
  257. - name: Upload linux-mipsle
  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-mipsle.tar.gz
  264. asset_name: nebula-linux-mipsle.tar.gz
  265. asset_content_type: application/gzip
  266. - name: Upload linux-mips64
  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-linux-mips64.tar.gz
  273. asset_name: nebula-linux-mips64.tar.gz
  274. asset_content_type: application/gzip
  275. - name: Upload linux-mips64le
  276. uses: actions/[email protected]
  277. env:
  278. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  279. with:
  280. upload_url: ${{ steps.create_release.outputs.upload_url }}
  281. asset_path: ./linux-latest/nebula-linux-mips64le.tar.gz
  282. asset_name: nebula-linux-mips64le.tar.gz
  283. asset_content_type: application/gzip
  284. - name: Upload linux-mips-softfloat
  285. uses: actions/[email protected]
  286. env:
  287. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  288. with:
  289. upload_url: ${{ steps.create_release.outputs.upload_url }}
  290. asset_path: ./linux-latest/nebula-linux-mips-softfloat.tar.gz
  291. asset_name: nebula-linux-mips-softfloat.tar.gz
  292. asset_content_type: application/gzip
  293. - name: Upload linux-riscv64
  294. uses: actions/[email protected]
  295. env:
  296. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  297. with:
  298. upload_url: ${{ steps.create_release.outputs.upload_url }}
  299. asset_path: ./linux-latest/nebula-linux-riscv64.tar.gz
  300. asset_name: nebula-linux-riscv64.tar.gz
  301. asset_content_type: application/gzip
  302. - name: Upload freebsd-amd64
  303. uses: actions/[email protected]
  304. env:
  305. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  306. with:
  307. upload_url: ${{ steps.create_release.outputs.upload_url }}
  308. asset_path: ./linux-latest/nebula-freebsd-amd64.tar.gz
  309. asset_name: nebula-freebsd-amd64.tar.gz
  310. asset_content_type: application/gzip