release.yml 8.5 KB

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