release.yml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. on:
  2. release:
  3. types: [published]
  4. name: Create release and upload binaries
  5. jobs:
  6. build-linux:
  7. name: Build Linux/BSD All
  8. runs-on: ubuntu-latest
  9. steps:
  10. - uses: actions/checkout@v6
  11. - uses: actions/setup-go@v6
  12. with:
  13. go-version: '1.25'
  14. check-latest: true
  15. - name: Build
  16. env:
  17. TAG: ${{ github.event.release.tag_name }}
  18. run: |
  19. make BUILD_NUMBER="${TAG#v}" release-linux release-freebsd release-openbsd release-netbsd
  20. mkdir release
  21. mv build/*.tar.gz release
  22. - name: Upload artifacts
  23. uses: actions/upload-artifact@v5
  24. with:
  25. name: linux-latest
  26. path: release
  27. build-windows:
  28. name: Build Windows
  29. runs-on: windows-latest
  30. steps:
  31. - uses: actions/checkout@v6
  32. - uses: actions/setup-go@v6
  33. with:
  34. go-version: '1.25'
  35. check-latest: true
  36. - name: Build
  37. env:
  38. TAG: ${{ github.event.release.tag_name }}
  39. run: |
  40. echo $Env:TAG.Substring(1)
  41. mkdir build\windows-amd64
  42. $Env:GOARCH = "amd64"
  43. go build -trimpath -ldflags "-X main.Build=$($Env:TAG.Substring(1))" -o build\windows-amd64\nebula.exe ./cmd/nebula-service
  44. go build -trimpath -ldflags "-X main.Build=$($Env:TAG.Substring(1))" -o build\windows-amd64\nebula-cert.exe ./cmd/nebula-cert
  45. mkdir build\windows-arm64
  46. $Env:GOARCH = "arm64"
  47. go build -trimpath -ldflags "-X main.Build=$($Env:TAG.Substring(1))" -o build\windows-arm64\nebula.exe ./cmd/nebula-service
  48. go build -trimpath -ldflags "-X main.Build=$($Env:TAG.Substring(1))" -o build\windows-arm64\nebula-cert.exe ./cmd/nebula-cert
  49. mkdir build\dist\windows
  50. mv dist\windows\wintun build\dist\windows\
  51. - name: Upload artifacts
  52. uses: actions/upload-artifact@v5
  53. with:
  54. name: windows-latest
  55. path: build
  56. build-darwin:
  57. name: Build Universal Darwin
  58. env:
  59. HAS_SIGNING_CREDS: ${{ secrets.AC_USERNAME != '' }}
  60. runs-on: macos-latest
  61. steps:
  62. - uses: actions/checkout@v6
  63. - uses: actions/setup-go@v6
  64. with:
  65. go-version: '1.25'
  66. check-latest: true
  67. - name: Import certificates
  68. if: env.HAS_SIGNING_CREDS == 'true'
  69. uses: Apple-Actions/import-codesign-certs@v6
  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. TAG: ${{ github.event.release.tag_name }}
  78. run: |
  79. rm -rf release
  80. mkdir release
  81. make BUILD_NUMBER="${TAG#v}" service build/darwin-amd64/nebula build/darwin-amd64/nebula-cert
  82. make BUILD_NUMBER="${TAG#v}" service build/darwin-arm64/nebula build/darwin-arm64/nebula-cert
  83. lipo -create -output ./release/nebula ./build/darwin-amd64/nebula ./build/darwin-arm64/nebula
  84. lipo -create -output ./release/nebula-cert ./build/darwin-amd64/nebula-cert ./build/darwin-arm64/nebula-cert
  85. if [ -n "$AC_USERNAME" ]; then
  86. codesign -s "10BC1FDDEB6CE753550156C0669109FAC49E4D1E" -f -v --timestamp --options=runtime -i "net.defined.nebula" ./release/nebula
  87. codesign -s "10BC1FDDEB6CE753550156C0669109FAC49E4D1E" -f -v --timestamp --options=runtime -i "net.defined.nebula-cert" ./release/nebula-cert
  88. fi
  89. zip -j release/nebula-darwin.zip release/nebula-cert release/nebula
  90. if [ -n "$AC_USERNAME" ]; then
  91. xcrun notarytool submit ./release/nebula-darwin.zip --team-id "576H3XS7FP" --apple-id "$AC_USERNAME" --password "$AC_PASSWORD" --wait
  92. fi
  93. - name: Upload artifacts
  94. uses: actions/upload-artifact@v5
  95. with:
  96. name: darwin-latest
  97. path: ./release/*
  98. build-docker:
  99. name: Create and Upload Docker Images
  100. # Technically we only need build-linux to succeed, but if any platforms fail we'll
  101. # want to investigate and restart the build
  102. needs: [build-linux, build-darwin, build-windows]
  103. runs-on: ubuntu-latest
  104. env:
  105. HAS_DOCKER_CREDS: ${{ vars.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }}
  106. # XXX It's not possible to write a conditional here, so instead we do it on every step
  107. #if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  108. steps:
  109. # Be sure to checkout the code before downloading artifacts, or they will
  110. # be overwritten
  111. - name: Checkout code
  112. if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  113. uses: actions/checkout@v6
  114. - name: Download artifacts
  115. if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  116. uses: actions/download-artifact@v6
  117. with:
  118. name: linux-latest
  119. path: artifacts
  120. - name: Login to Docker Hub
  121. if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  122. uses: docker/login-action@v3
  123. with:
  124. username: ${{ vars.DOCKERHUB_USERNAME }}
  125. password: ${{ secrets.DOCKERHUB_TOKEN }}
  126. - name: Set up Docker Buildx
  127. if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  128. uses: docker/setup-buildx-action@v3
  129. - name: Build and push images
  130. if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  131. env:
  132. DOCKER_IMAGE_REPO: ${{ vars.DOCKER_IMAGE_REPO || 'nebulaoss/nebula' }}
  133. DOCKER_IMAGE_TAG: ${{ vars.DOCKER_IMAGE_TAG || 'latest' }}
  134. TAG: ${{ github.event.release.tag_name }}
  135. run: |
  136. mkdir -p build/linux-{amd64,arm64}
  137. tar -zxvf artifacts/nebula-linux-amd64.tar.gz -C build/linux-amd64/
  138. tar -zxvf artifacts/nebula-linux-arm64.tar.gz -C build/linux-arm64/
  139. docker buildx build . --push -f docker/Dockerfile --platform linux/amd64,linux/arm64 --tag "${DOCKER_IMAGE_REPO}:${DOCKER_IMAGE_TAG}" --tag "${DOCKER_IMAGE_REPO}:${TAG#v}"
  140. release:
  141. name: Create and Upload Release
  142. needs: [build-linux, build-darwin, build-windows]
  143. runs-on: ubuntu-latest
  144. steps:
  145. - uses: actions/checkout@v6
  146. - name: Download artifacts
  147. uses: actions/download-artifact@v6
  148. with:
  149. path: artifacts
  150. - name: Zip Windows
  151. run: |
  152. cd artifacts/windows-latest
  153. cp windows-amd64/* .
  154. zip -r nebula-windows-amd64.zip nebula.exe nebula-cert.exe dist
  155. cp windows-arm64/* .
  156. zip -r nebula-windows-arm64.zip nebula.exe nebula-cert.exe dist
  157. - name: Create sha256sum
  158. run: |
  159. cd artifacts
  160. for dir in linux-latest darwin-latest windows-latest
  161. do
  162. (
  163. cd $dir
  164. if [ "$dir" = windows-latest ]
  165. then
  166. sha256sum <windows-amd64/nebula.exe | sed 's=-$=nebula-windows-amd64.zip/nebula.exe='
  167. sha256sum <windows-amd64/nebula-cert.exe | sed 's=-$=nebula-windows-amd64.zip/nebula-cert.exe='
  168. sha256sum <windows-arm64/nebula.exe | sed 's=-$=nebula-windows-arm64.zip/nebula.exe='
  169. sha256sum <windows-arm64/nebula-cert.exe | sed 's=-$=nebula-windows-arm64.zip/nebula-cert.exe='
  170. sha256sum nebula-windows-amd64.zip
  171. sha256sum nebula-windows-arm64.zip
  172. elif [ "$dir" = darwin-latest ]
  173. then
  174. sha256sum <nebula-darwin.zip | sed 's=-$=nebula-darwin.zip='
  175. sha256sum <nebula | sed 's=-$=nebula-darwin.zip/nebula='
  176. sha256sum <nebula-cert | sed 's=-$=nebula-darwin.zip/nebula-cert='
  177. else
  178. for v in *.tar.gz
  179. do
  180. sha256sum $v
  181. tar zxf $v --to-command='sh -c "sha256sum | sed s=-$='$v'/$TAR_FILENAME="'
  182. done
  183. fi
  184. )
  185. done | sort -k 2 >SHASUM256.txt
  186. - name: Create Release
  187. id: create_release
  188. env:
  189. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  190. run: |
  191. cd artifacts
  192. gh release upload \
  193. "${{ github.event.release.tag_name }}" \
  194. SHASUM256.txt *-latest/*.zip *-latest/*.tar.gz