build-syncthing.yaml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. name: Build Syncthing
  2. on:
  3. pull_request:
  4. push:
  5. env:
  6. # The go version to use for builds.
  7. GO_VERSION: "1.19.4"
  8. # Optimize compatibility on the slow archictures.
  9. GO386: softfloat
  10. GOARM: "5"
  11. GOMIPS: softfloat
  12. # Avoid hilarious amounts of obscuring log output when running tests.
  13. LOGGER_DISCARD: "1"
  14. # Our build metadata
  15. BUILD_USER: builder
  16. BUILD_HOST: github.syncthing.net
  17. # A note on actions and third party code... The actions under actions/ (like
  18. # `uses: actions/checkout`) are maintained by GitHub, and we need to trust
  19. # GitHub to maintain their code and infrastructure or we're in deep shit in
  20. # general. The same doesn't necessarily apply to other actions authors, so
  21. # some care needs to be taken when adding steps, especially in the paths
  22. # that lead up to code being packaged and signed.
  23. jobs:
  24. #
  25. # Windows, quick build and test, runs always
  26. #
  27. build-windows:
  28. name: Build and test on Windows
  29. runs-on: windows-latest
  30. steps:
  31. - name: Set git to use LF
  32. # Without this, the checkout will happen with CRLF line endings,
  33. # which is fine for the source code but messes up tests that depend
  34. # on data on disk being as expected. Ideally, those tests should be
  35. # fixed, but not today.
  36. run: |
  37. git config --global core.autocrlf false
  38. git config --global core.eol lf
  39. - uses: actions/checkout@v3
  40. - uses: actions/setup-go@v3
  41. # `cache: true` gives us automatic caching of modules and build
  42. # cache, speeding up builds. The cache key is dependent on the Go
  43. # version and our go.sum contents.
  44. with:
  45. go-version: ${{ env.GO_VERSION }}
  46. cache: true
  47. - name: Build and test
  48. run: |
  49. go run build.go
  50. go run build.go test
  51. #
  52. # Windows, build signed packages
  53. #
  54. package-windows:
  55. name: Create packages for Windows
  56. runs-on: windows-latest
  57. # We only run this job for release pushes.
  58. if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release')
  59. # This is also enforced by the environment which contains the secrets.
  60. environment: signing
  61. needs:
  62. - build-windows
  63. steps:
  64. - name: Set git to use LF
  65. run: |
  66. git config --global core.autocrlf false
  67. git config --global core.eol lf
  68. - uses: actions/checkout@v3
  69. # `fetch-depth: 0` because we want to check out the entire repo
  70. # including tags and branches, not just the latest commit which
  71. # lacks version info.
  72. with:
  73. fetch-depth: 0
  74. - uses: actions/setup-go@v3
  75. with:
  76. go-version: ${{ env.GO_VERSION }}
  77. - uses: actions/cache@v3
  78. with:
  79. path: |
  80. ~\AppData\Local\go-build
  81. ~\go\pkg\mod
  82. key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-package-${{ hashFiles('**/go.sum') }}
  83. - name: Install dependencies
  84. run: |
  85. go install github.com/josephspurrier/goversioninfo/cmd/[email protected]
  86. - name: Create packages
  87. run: |
  88. go run build.go -goarch amd64 zip
  89. go run build.go -goarch arm zip
  90. go run build.go -goarch arm64 zip
  91. go run build.go -goarch 386 zip
  92. env:
  93. CODESIGN_SIGNTOOL: ${{ secrets.CODESIGN_SIGNTOOL }}
  94. CODESIGN_CERTIFICATE_BASE64: ${{ secrets.CODESIGN_CERTIFICATE_BASE64 }}
  95. CODESIGN_CERTIFICATE_PASSWORD: ${{ secrets.CODESIGN_CERTIFICATE_PASSWORD }}
  96. CODESIGN_TIMESTAMP_SERVER: ${{ secrets.CODESIGN_TIMESTAMP_SERVER }}
  97. - name: Archive artifacts
  98. uses: actions/upload-artifact@v3
  99. with:
  100. name: packages
  101. path: syncthing-windows-*.zip