release.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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.19
  12. uses: actions/setup-go@v2
  13. with:
  14. go-version: 1.19
  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@v2
  24. with:
  25. name: linux-latest
  26. path: release
  27. build-windows:
  28. name: Build Windows
  29. runs-on: windows-latest
  30. steps:
  31. - name: Set up Go 1.19
  32. uses: actions/setup-go@v2
  33. with:
  34. go-version: 1.19
  35. - name: Checkout code
  36. uses: actions/checkout@v2
  37. - name: Build
  38. run: |
  39. echo $Env:GITHUB_REF.Substring(11)
  40. mkdir build\windows-amd64
  41. $Env:GOARCH = "amd64"
  42. go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\windows-amd64\nebula.exe ./cmd/nebula-service
  43. go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\windows-amd64\nebula-cert.exe ./cmd/nebula-cert
  44. mkdir build\windows-arm64
  45. $Env:GOARCH = "arm64"
  46. go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\windows-arm64\nebula.exe ./cmd/nebula-service
  47. go build -trimpath -ldflags "-X main.Build=$($Env:GITHUB_REF.Substring(11))" -o build\windows-arm64\nebula-cert.exe ./cmd/nebula-cert
  48. mkdir build\dist\windows
  49. mv dist\windows\wintun build\dist\windows\
  50. - name: Upload artifacts
  51. uses: actions/upload-artifact@v2
  52. with:
  53. name: windows-latest
  54. path: build
  55. build-darwin:
  56. name: Build Universal Darwin
  57. env:
  58. HAS_SIGNING_CREDS: ${{ secrets.AC_USERNAME != '' }}
  59. runs-on: macos-11
  60. steps:
  61. - name: Set up Go 1.19
  62. uses: actions/setup-go@v2
  63. with:
  64. go-version: 1.19
  65. - name: Checkout code
  66. uses: actions/checkout@v2
  67. - name: Import certificates
  68. if: env.HAS_SIGNING_CREDS == 'true'
  69. uses: Apple-Actions/import-codesign-certs@v1
  70. with:
  71. p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
  72. p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
  73. - name: Build, sign, and notarize
  74. env:
  75. AC_USERNAME: ${{ secrets.AC_USERNAME }}
  76. AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
  77. run: |
  78. rm -rf release
  79. mkdir release
  80. make BUILD_NUMBER="${GITHUB_REF#refs/tags/v}" service build/darwin-amd64/nebula build/darwin-amd64/nebula-cert
  81. make BUILD_NUMBER="${GITHUB_REF#refs/tags/v}" service build/darwin-arm64/nebula build/darwin-arm64/nebula-cert
  82. lipo -create -output ./release/nebula ./build/darwin-amd64/nebula ./build/darwin-arm64/nebula
  83. lipo -create -output ./release/nebula-cert ./build/darwin-amd64/nebula-cert ./build/darwin-arm64/nebula-cert
  84. if [ -n "$AC_USERNAME" ]; then
  85. codesign -s "10BC1FDDEB6CE753550156C0669109FAC49E4D1E" -f -v --timestamp --options=runtime -i "net.defined.nebula" ./release/nebula
  86. codesign -s "10BC1FDDEB6CE753550156C0669109FAC49E4D1E" -f -v --timestamp --options=runtime -i "net.defined.nebula-cert" ./release/nebula-cert
  87. fi
  88. zip -j release/nebula-darwin.zip release/nebula-cert release/nebula
  89. if [ -n "$AC_USERNAME" ]; then
  90. xcrun notarytool submit ./release/nebula-darwin.zip --team-id "576H3XS7FP" --apple-id "$AC_USERNAME" --password "$AC_PASSWORD" --wait
  91. fi
  92. - name: Upload artifacts
  93. uses: actions/upload-artifact@v2
  94. with:
  95. name: darwin-latest
  96. path: ./release/*
  97. release:
  98. name: Create and Upload Release
  99. needs: [build-linux, build-darwin, build-windows]
  100. runs-on: ubuntu-latest
  101. steps:
  102. - name: Download artifacts
  103. uses: actions/download-artifact@v2
  104. - name: Zip Windows
  105. run: |
  106. cd windows-latest
  107. cp windows-amd64/* .
  108. zip -r nebula-windows-amd64.zip nebula.exe nebula-cert.exe dist
  109. cp windows-arm64/* .
  110. zip -r nebula-windows-arm64.zip nebula.exe nebula-cert.exe dist
  111. - name: Create sha256sum
  112. run: |
  113. for dir in linux-latest darwin-latest windows-latest
  114. do
  115. (
  116. cd $dir
  117. if [ "$dir" = windows-latest ]
  118. then
  119. sha256sum <windows-amd64/nebula.exe | sed 's=-$=nebula-windows-amd64.zip/nebula.exe='
  120. sha256sum <windows-amd64/nebula-cert.exe | sed 's=-$=nebula-windows-amd64.zip/nebula-cert.exe='
  121. sha256sum <windows-arm64/nebula.exe | sed 's=-$=nebula-windows-arm64.zip/nebula.exe='
  122. sha256sum <windows-arm64/nebula-cert.exe | sed 's=-$=nebula-windows-arm64.zip/nebula-cert.exe='
  123. sha256sum nebula-windows-amd64.zip
  124. sha256sum nebula-windows-arm64.zip
  125. elif [ "$dir" = darwin-latest ]
  126. then
  127. sha256sum <nebula-darwin.zip | sed 's=-$=nebula-darwin.zip='
  128. sha256sum <nebula | sed 's=-$=nebula-darwin.zip/nebula='
  129. sha256sum <nebula-cert | sed 's=-$=nebula-darwin.zip/nebula-cert='
  130. else
  131. for v in *.tar.gz
  132. do
  133. sha256sum $v
  134. tar zxf $v --to-command='sh -c "sha256sum | sed s=-$='$v'/$TAR_FILENAME="'
  135. done
  136. fi
  137. )
  138. done | sort -k 2 >SHASUM256.txt
  139. - name: Create Release
  140. id: create_release
  141. uses: actions/create-release@v1
  142. env:
  143. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  144. with:
  145. tag_name: ${{ github.ref }}
  146. release_name: Release ${{ github.ref }}
  147. draft: false
  148. prerelease: false
  149. ##
  150. ## Upload assets (I wish we could just upload the whole folder at once...
  151. ##
  152. - name: Upload SHASUM256.txt
  153. uses: actions/[email protected]
  154. env:
  155. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  156. with:
  157. upload_url: ${{ steps.create_release.outputs.upload_url }}
  158. asset_path: ./SHASUM256.txt
  159. asset_name: SHASUM256.txt
  160. asset_content_type: text/plain
  161. - name: Upload darwin zip
  162. uses: actions/[email protected]
  163. env:
  164. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  165. with:
  166. upload_url: ${{ steps.create_release.outputs.upload_url }}
  167. asset_path: ./darwin-latest/nebula-darwin.zip
  168. asset_name: nebula-darwin.zip
  169. asset_content_type: application/zip
  170. - name: Upload windows-amd64
  171. uses: actions/[email protected]
  172. env:
  173. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  174. with:
  175. upload_url: ${{ steps.create_release.outputs.upload_url }}
  176. asset_path: ./windows-latest/nebula-windows-amd64.zip
  177. asset_name: nebula-windows-amd64.zip
  178. asset_content_type: application/zip
  179. - name: Upload windows-arm64
  180. uses: actions/[email protected]
  181. env:
  182. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  183. with:
  184. upload_url: ${{ steps.create_release.outputs.upload_url }}
  185. asset_path: ./windows-latest/nebula-windows-arm64.zip
  186. asset_name: nebula-windows-arm64.zip
  187. asset_content_type: application/zip
  188. - name: Upload linux-amd64
  189. uses: actions/[email protected]
  190. env:
  191. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  192. with:
  193. upload_url: ${{ steps.create_release.outputs.upload_url }}
  194. asset_path: ./linux-latest/nebula-linux-amd64.tar.gz
  195. asset_name: nebula-linux-amd64.tar.gz
  196. asset_content_type: application/gzip
  197. - name: Upload linux-386
  198. uses: actions/[email protected]
  199. env:
  200. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  201. with:
  202. upload_url: ${{ steps.create_release.outputs.upload_url }}
  203. asset_path: ./linux-latest/nebula-linux-386.tar.gz
  204. asset_name: nebula-linux-386.tar.gz
  205. asset_content_type: application/gzip
  206. - name: Upload linux-ppc64le
  207. uses: actions/[email protected]
  208. env:
  209. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  210. with:
  211. upload_url: ${{ steps.create_release.outputs.upload_url }}
  212. asset_path: ./linux-latest/nebula-linux-ppc64le.tar.gz
  213. asset_name: nebula-linux-ppc64le.tar.gz
  214. asset_content_type: application/gzip
  215. - name: Upload linux-arm-5
  216. uses: actions/[email protected]
  217. env:
  218. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  219. with:
  220. upload_url: ${{ steps.create_release.outputs.upload_url }}
  221. asset_path: ./linux-latest/nebula-linux-arm-5.tar.gz
  222. asset_name: nebula-linux-arm-5.tar.gz
  223. asset_content_type: application/gzip
  224. - name: Upload linux-arm-6
  225. uses: actions/[email protected]
  226. env:
  227. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  228. with:
  229. upload_url: ${{ steps.create_release.outputs.upload_url }}
  230. asset_path: ./linux-latest/nebula-linux-arm-6.tar.gz
  231. asset_name: nebula-linux-arm-6.tar.gz
  232. asset_content_type: application/gzip
  233. - name: Upload linux-arm-7
  234. uses: actions/[email protected]
  235. env:
  236. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  237. with:
  238. upload_url: ${{ steps.create_release.outputs.upload_url }}
  239. asset_path: ./linux-latest/nebula-linux-arm-7.tar.gz
  240. asset_name: nebula-linux-arm-7.tar.gz
  241. asset_content_type: application/gzip
  242. - name: Upload linux-arm64
  243. uses: actions/[email protected]
  244. env:
  245. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  246. with:
  247. upload_url: ${{ steps.create_release.outputs.upload_url }}
  248. asset_path: ./linux-latest/nebula-linux-arm64.tar.gz
  249. asset_name: nebula-linux-arm64.tar.gz
  250. asset_content_type: application/gzip
  251. - name: Upload linux-mips
  252. uses: actions/[email protected]
  253. env:
  254. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  255. with:
  256. upload_url: ${{ steps.create_release.outputs.upload_url }}
  257. asset_path: ./linux-latest/nebula-linux-mips.tar.gz
  258. asset_name: nebula-linux-mips.tar.gz
  259. asset_content_type: application/gzip
  260. - name: Upload linux-mipsle
  261. uses: actions/[email protected]
  262. env:
  263. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  264. with:
  265. upload_url: ${{ steps.create_release.outputs.upload_url }}
  266. asset_path: ./linux-latest/nebula-linux-mipsle.tar.gz
  267. asset_name: nebula-linux-mipsle.tar.gz
  268. asset_content_type: application/gzip
  269. - name: Upload linux-mips64
  270. uses: actions/[email protected]
  271. env:
  272. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  273. with:
  274. upload_url: ${{ steps.create_release.outputs.upload_url }}
  275. asset_path: ./linux-latest/nebula-linux-mips64.tar.gz
  276. asset_name: nebula-linux-mips64.tar.gz
  277. asset_content_type: application/gzip
  278. - name: Upload linux-mips64le
  279. uses: actions/[email protected]
  280. env:
  281. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  282. with:
  283. upload_url: ${{ steps.create_release.outputs.upload_url }}
  284. asset_path: ./linux-latest/nebula-linux-mips64le.tar.gz
  285. asset_name: nebula-linux-mips64le.tar.gz
  286. asset_content_type: application/gzip
  287. - name: Upload linux-mips-softfloat
  288. uses: actions/[email protected]
  289. env:
  290. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  291. with:
  292. upload_url: ${{ steps.create_release.outputs.upload_url }}
  293. asset_path: ./linux-latest/nebula-linux-mips-softfloat.tar.gz
  294. asset_name: nebula-linux-mips-softfloat.tar.gz
  295. asset_content_type: application/gzip
  296. - name: Upload linux-riscv64
  297. uses: actions/[email protected]
  298. env:
  299. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  300. with:
  301. upload_url: ${{ steps.create_release.outputs.upload_url }}
  302. asset_path: ./linux-latest/nebula-linux-riscv64.tar.gz
  303. asset_name: nebula-linux-riscv64.tar.gz
  304. asset_content_type: application/gzip
  305. - name: Upload freebsd-amd64
  306. uses: actions/[email protected]
  307. env:
  308. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  309. with:
  310. upload_url: ${{ steps.create_release.outputs.upload_url }}
  311. asset_path: ./linux-latest/nebula-freebsd-amd64.tar.gz
  312. asset_name: nebula-freebsd-amd64.tar.gz
  313. asset_content_type: application/gzip