release.yml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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@v4
  12. - uses: actions/setup-go@v5
  13. with:
  14. go-version: '1.23'
  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@v4
  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@v4
  31. - uses: actions/setup-go@v5
  32. with:
  33. go-version: '1.23'
  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@v4
  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-latest
  58. steps:
  59. - uses: actions/checkout@v4
  60. - uses: actions/setup-go@v5
  61. with:
  62. go-version: '1.23'
  63. check-latest: true
  64. - name: Import certificates
  65. if: env.HAS_SIGNING_CREDS == 'true'
  66. uses: Apple-Actions/import-codesign-certs@v3
  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@v4
  91. with:
  92. name: darwin-latest
  93. path: ./release/*
  94. build-docker:
  95. name: Create and Upload Docker Images
  96. # Technically we only need build-linux to succeed, but if any platforms fail we'll
  97. # want to investigate and restart the build
  98. needs: [build-linux, build-darwin, build-windows]
  99. runs-on: ubuntu-latest
  100. env:
  101. HAS_DOCKER_CREDS: ${{ vars.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }}
  102. # XXX It's not possible to write a conditional here, so instead we do it on every step
  103. #if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  104. steps:
  105. # Be sure to checkout the code before downloading artifacts, or they will
  106. # be overwritten
  107. - name: Checkout code
  108. if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  109. uses: actions/checkout@v4
  110. - name: Download artifacts
  111. if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  112. uses: actions/download-artifact@v4
  113. with:
  114. name: linux-latest
  115. path: artifacts
  116. - name: Login to Docker Hub
  117. if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  118. uses: docker/login-action@v3
  119. with:
  120. username: ${{ vars.DOCKERHUB_USERNAME }}
  121. password: ${{ secrets.DOCKERHUB_TOKEN }}
  122. - name: Set up Docker Buildx
  123. if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  124. uses: docker/setup-buildx-action@v3
  125. - name: Build and push images
  126. if: ${{ env.HAS_DOCKER_CREDS == 'true' }}
  127. env:
  128. DOCKER_IMAGE_REPO: ${{ vars.DOCKER_IMAGE_REPO || 'nebulaoss/nebula' }}
  129. DOCKER_IMAGE_TAG: ${{ vars.DOCKER_IMAGE_TAG || 'latest' }}
  130. run: |
  131. mkdir -p build/linux-{amd64,arm64}
  132. tar -zxvf artifacts/nebula-linux-amd64.tar.gz -C build/linux-amd64/
  133. tar -zxvf artifacts/nebula-linux-arm64.tar.gz -C build/linux-arm64/
  134. docker buildx build . --push -f docker/Dockerfile --platform linux/amd64,linux/arm64 --tag "${DOCKER_IMAGE_REPO}:${DOCKER_IMAGE_TAG}" --tag "${DOCKER_IMAGE_REPO}:${GITHUB_REF#refs/tags/v}"
  135. release:
  136. name: Create and Upload Release
  137. needs: [build-linux, build-darwin, build-windows]
  138. runs-on: ubuntu-latest
  139. steps:
  140. - uses: actions/checkout@v4
  141. - name: Download artifacts
  142. uses: actions/download-artifact@v4
  143. with:
  144. path: artifacts
  145. - name: Zip Windows
  146. run: |
  147. cd artifacts/windows-latest
  148. cp windows-amd64/* .
  149. zip -r nebula-windows-amd64.zip nebula.exe nebula-cert.exe dist
  150. cp windows-arm64/* .
  151. zip -r nebula-windows-arm64.zip nebula.exe nebula-cert.exe dist
  152. - name: Create sha256sum
  153. run: |
  154. cd artifacts
  155. for dir in linux-latest darwin-latest windows-latest
  156. do
  157. (
  158. cd $dir
  159. if [ "$dir" = windows-latest ]
  160. then
  161. sha256sum <windows-amd64/nebula.exe | sed 's=-$=nebula-windows-amd64.zip/nebula.exe='
  162. sha256sum <windows-amd64/nebula-cert.exe | sed 's=-$=nebula-windows-amd64.zip/nebula-cert.exe='
  163. sha256sum <windows-arm64/nebula.exe | sed 's=-$=nebula-windows-arm64.zip/nebula.exe='
  164. sha256sum <windows-arm64/nebula-cert.exe | sed 's=-$=nebula-windows-arm64.zip/nebula-cert.exe='
  165. sha256sum nebula-windows-amd64.zip
  166. sha256sum nebula-windows-arm64.zip
  167. elif [ "$dir" = darwin-latest ]
  168. then
  169. sha256sum <nebula-darwin.zip | sed 's=-$=nebula-darwin.zip='
  170. sha256sum <nebula | sed 's=-$=nebula-darwin.zip/nebula='
  171. sha256sum <nebula-cert | sed 's=-$=nebula-darwin.zip/nebula-cert='
  172. else
  173. for v in *.tar.gz
  174. do
  175. sha256sum $v
  176. tar zxf $v --to-command='sh -c "sha256sum | sed s=-$='$v'/$TAR_FILENAME="'
  177. done
  178. fi
  179. )
  180. done | sort -k 2 >SHASUM256.txt
  181. - name: Create Release
  182. id: create_release
  183. env:
  184. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  185. run: |
  186. cd artifacts
  187. gh release create \
  188. --verify-tag \
  189. --title "Release ${{ github.ref_name }}" \
  190. "${{ github.ref_name }}" \
  191. SHASUM256.txt *-latest/*.zip *-latest/*.tar.gz