release.yml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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@v3
  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@v3
  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@v3
  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. - uses: actions/checkout@v3
  100. - name: Download artifacts
  101. uses: actions/download-artifact@v3
  102. with:
  103. path: artifacts
  104. - name: Zip Windows
  105. run: |
  106. cd artifacts/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. cd artifacts
  114. for dir in linux-latest darwin-latest windows-latest
  115. do
  116. (
  117. cd $dir
  118. if [ "$dir" = windows-latest ]
  119. then
  120. sha256sum <windows-amd64/nebula.exe | sed 's=-$=nebula-windows-amd64.zip/nebula.exe='
  121. sha256sum <windows-amd64/nebula-cert.exe | sed 's=-$=nebula-windows-amd64.zip/nebula-cert.exe='
  122. sha256sum <windows-arm64/nebula.exe | sed 's=-$=nebula-windows-arm64.zip/nebula.exe='
  123. sha256sum <windows-arm64/nebula-cert.exe | sed 's=-$=nebula-windows-arm64.zip/nebula-cert.exe='
  124. sha256sum nebula-windows-amd64.zip
  125. sha256sum nebula-windows-arm64.zip
  126. elif [ "$dir" = darwin-latest ]
  127. then
  128. sha256sum <nebula-darwin.zip | sed 's=-$=nebula-darwin.zip='
  129. sha256sum <nebula | sed 's=-$=nebula-darwin.zip/nebula='
  130. sha256sum <nebula-cert | sed 's=-$=nebula-darwin.zip/nebula-cert='
  131. else
  132. for v in *.tar.gz
  133. do
  134. sha256sum $v
  135. tar zxf $v --to-command='sh -c "sha256sum | sed s=-$='$v'/$TAR_FILENAME="'
  136. done
  137. fi
  138. )
  139. done | sort -k 2 >SHASUM256.txt
  140. - name: Create Release
  141. id: create_release
  142. env:
  143. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  144. run: |
  145. cd artifacts
  146. gh release create \
  147. --verify-tag \
  148. --title "Release ${{ github.ref_name }}" \
  149. "${{ github.ref_name }}" \
  150. SHASUM256.txt *-latest/*.zip *-latest/*.tar.gz