build-syncthing.yaml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853
  1. name: Build Syncthing
  2. on:
  3. pull_request:
  4. push:
  5. schedule:
  6. # Run nightly build at 05:00 UTC
  7. - cron: '00 05 * * *'
  8. workflow_dispatch:
  9. env:
  10. # The go version to use for builds. We set check-latest to true when
  11. # installing, so we get the latest patch version that matches the
  12. # expression.
  13. GO_VERSION: "~1.23.0"
  14. # Optimize compatibility on the slow archictures.
  15. GO386: softfloat
  16. GOARM: "5"
  17. GOMIPS: softfloat
  18. # Avoid hilarious amounts of obscuring log output when running tests.
  19. LOGGER_DISCARD: "1"
  20. # Our build metadata
  21. BUILD_USER: builder
  22. BUILD_HOST: github.syncthing.net
  23. # A note on actions and third party code... The actions under actions/ (like
  24. # `uses: actions/checkout`) are maintained by GitHub, and we need to trust
  25. # GitHub to maintain their code and infrastructure or we're in deep shit in
  26. # general. The same doesn't necessarily apply to other actions authors, so
  27. # some care needs to be taken when adding steps, especially in the paths
  28. # that lead up to code being packaged and signed.
  29. jobs:
  30. #
  31. # Tests for all platforms. Runs a matrix build on Windows, Linux and Mac,
  32. # with the list of expected supported Go versions (current, previous).
  33. #
  34. build-test:
  35. name: Build and test
  36. strategy:
  37. fail-fast: false
  38. matrix:
  39. runner: ["windows-latest", "ubuntu-latest", "macos-latest"]
  40. # The oldest version in this list should match what we have in our go.mod.
  41. # Variables don't seem to be supported here, or we could have done something nice.
  42. go: ["~1.22.6", "~1.23.0"]
  43. runs-on: ${{ matrix.runner }}
  44. steps:
  45. - name: Set git to use LF
  46. if: matrix.runner == 'windows-latest'
  47. # Without this, the Windows checkout will happen with CRLF line
  48. # endings, which is fine for the source code but messes up tests
  49. # that depend on data on disk being as expected. Ideally, those
  50. # tests should be fixed, but not today.
  51. run: |
  52. git config --global core.autocrlf false
  53. git config --global core.eol lf
  54. - uses: actions/checkout@v4
  55. - uses: actions/setup-go@v5
  56. with:
  57. go-version: ${{ matrix.go }}
  58. cache: true
  59. check-latest: true
  60. - name: Build
  61. run: |
  62. go run build.go
  63. - name: Install go-test-json-to-loki
  64. run: |
  65. go install calmh.dev/go-test-json-to-loki@latest
  66. - name: Test
  67. run: |
  68. go version
  69. go run build.go test | go-test-json-to-loki
  70. env:
  71. GOFLAGS: "-json"
  72. LOKI_URL: ${{ vars.LOKI_URL }}
  73. LOKI_USER: ${{ vars.LOKI_USER }}
  74. LOKI_PASSWORD: ${{ secrets.LOKI_PASSWORD }}
  75. LOKI_LABELS: "go=${{ matrix.go }},runner=${{ matrix.runner }},repo=${{ github.repository }},ref=${{ github.ref }}"
  76. #
  77. # Meta checks for formatting, copyright, etc
  78. #
  79. correctness:
  80. name: Check correctness
  81. runs-on: ubuntu-latest
  82. steps:
  83. - uses: actions/checkout@v4
  84. - uses: actions/setup-go@v5
  85. with:
  86. go-version: ${{ env.GO_VERSION }}
  87. cache: false
  88. check-latest: true
  89. - name: Check correctness
  90. run: |
  91. go test -v ./meta
  92. #
  93. # The basic checks job is a virtual one that depends on the matrix tests,
  94. # the correctness checks, and various builds that we always do. This makes
  95. # it easy to have the PR process have a single test as a gatekeeper for
  96. # merging, instead of having to add all the matrix tests and update them
  97. # each time the version changes. (The top level test is not available for
  98. # choosing there, only the matrix "children".)
  99. #
  100. basics:
  101. name: Basic checks passed
  102. runs-on: ubuntu-latest
  103. needs:
  104. - build-test
  105. - correctness
  106. - package-linux
  107. - package-cross
  108. - package-source
  109. - package-debian
  110. - govulncheck
  111. steps:
  112. - uses: actions/checkout@v4
  113. #
  114. # Windows
  115. #
  116. package-windows:
  117. name: Package for Windows
  118. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref == 'refs/heads/release' || startsWith(github.ref, 'refs/heads/release-'))
  119. environment: signing
  120. runs-on: windows-latest
  121. steps:
  122. - name: Set git to use LF
  123. # Without this, the checkout will happen with CRLF line endings,
  124. # which is fine for the source code but messes up tests that depend
  125. # on data on disk being as expected. Ideally, those tests should be
  126. # fixed, but not today.
  127. run: |
  128. git config --global core.autocrlf false
  129. git config --global core.eol lf
  130. - uses: actions/checkout@v4
  131. with:
  132. fetch-depth: 0
  133. - uses: actions/setup-go@v5
  134. with:
  135. go-version: ${{ env.GO_VERSION }}
  136. cache: false
  137. check-latest: true
  138. - name: Get actual Go version
  139. run: |
  140. go version
  141. echo "GO_VERSION=$(go version | sed 's#^.*go##;s# .*##')" >> $GITHUB_ENV
  142. - uses: actions/cache@v4
  143. with:
  144. path: |
  145. ~\AppData\Local\go-build
  146. ~\go\pkg\mod
  147. key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-package-${{ hashFiles('**/go.sum') }}
  148. - name: Install dependencies
  149. run: |
  150. go install github.com/josephspurrier/goversioninfo/cmd/[email protected]
  151. - name: Create packages
  152. run: |
  153. go run build.go -goarch amd64 zip
  154. go run build.go -goarch arm zip
  155. go run build.go -goarch arm64 zip
  156. go run build.go -goarch 386 zip
  157. env:
  158. CGO_ENABLED: "0"
  159. CODESIGN_SIGNTOOL: ${{ secrets.CODESIGN_SIGNTOOL }}
  160. CODESIGN_CERTIFICATE_BASE64: ${{ secrets.CODESIGN_CERTIFICATE_BASE64 }}
  161. CODESIGN_CERTIFICATE_PASSWORD: ${{ secrets.CODESIGN_CERTIFICATE_PASSWORD }}
  162. CODESIGN_TIMESTAMP_SERVER: ${{ secrets.CODESIGN_TIMESTAMP_SERVER }}
  163. - name: Archive artifacts
  164. uses: actions/upload-artifact@v4
  165. with:
  166. name: packages-windows
  167. path: syncthing-windows-*.zip
  168. #
  169. # Linux
  170. #
  171. package-linux:
  172. name: Package for Linux
  173. runs-on: ubuntu-latest
  174. steps:
  175. - uses: actions/checkout@v4
  176. with:
  177. fetch-depth: 0
  178. - uses: actions/setup-go@v5
  179. with:
  180. go-version: ${{ env.GO_VERSION }}
  181. cache: false
  182. check-latest: true
  183. - name: Get actual Go version
  184. run: |
  185. go version
  186. echo "GO_VERSION=$(go version | sed 's#^.*go##;s# .*##')" >> $GITHUB_ENV
  187. - uses: actions/cache@v4
  188. with:
  189. path: |
  190. ~/.cache/go-build
  191. ~/go/pkg/mod
  192. key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-package-${{ hashFiles('**/go.sum') }}
  193. - name: Create packages
  194. run: |
  195. archs=$(go tool dist list | grep linux | sed 's#linux/##')
  196. for goarch in $archs ; do
  197. go run build.go -goarch "$goarch" tar
  198. done
  199. env:
  200. CGO_ENABLED: "0"
  201. - name: Archive artifacts
  202. uses: actions/upload-artifact@v4
  203. with:
  204. name: packages-linux
  205. path: |
  206. syncthing-linux-*.tar.gz
  207. compat.json
  208. #
  209. # macOS
  210. #
  211. package-macos:
  212. name: Package for macOS
  213. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref == 'refs/heads/release' || startsWith(github.ref, 'refs/heads/release-'))
  214. environment: signing
  215. runs-on: macos-latest
  216. steps:
  217. - uses: actions/checkout@v4
  218. with:
  219. fetch-depth: 0
  220. - uses: actions/setup-go@v5
  221. with:
  222. go-version: ${{ env.GO_VERSION }}
  223. cache: false
  224. check-latest: true
  225. - name: Get actual Go version
  226. run: |
  227. go version
  228. echo "GO_VERSION=$(go version | sed 's#^.*go##;s# .*##')" >> $GITHUB_ENV
  229. - uses: actions/cache@v4
  230. with:
  231. path: |
  232. ~/.cache/go-build
  233. ~/go/pkg/mod
  234. key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-package-${{ hashFiles('**/go.sum') }}
  235. - name: Import signing certificate
  236. run: |
  237. # Set up a run-specific keychain, making it available for the
  238. # `codesign` tool.
  239. umask 066
  240. KEYCHAIN_PATH=$RUNNER_TEMP/codesign.keychain
  241. KEYCHAIN_PASSWORD=$(uuidgen)
  242. security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
  243. security default-keychain -s "$KEYCHAIN_PATH"
  244. security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
  245. security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
  246. # Import the certificate
  247. CERTIFICATE_PATH=$RUNNER_TEMP/codesign.p12
  248. echo "$DEVELOPER_ID_CERTIFICATE_BASE64" | base64 -d -o "$CERTIFICATE_PATH"
  249. security import "$CERTIFICATE_PATH" -k "$KEYCHAIN_PATH" -P "$DEVELOPER_ID_CERTIFICATE_PASSWORD" -T /usr/bin/codesign -T /usr/bin/productsign
  250. security set-key-partition-list -S apple-tool:,apple: -s -k actions "$KEYCHAIN_PATH"
  251. # Set the codesign identity for following steps
  252. echo "CODESIGN_IDENTITY=$CODESIGN_IDENTITY" >> $GITHUB_ENV
  253. env:
  254. DEVELOPER_ID_CERTIFICATE_BASE64: ${{ secrets.DEVELOPER_ID_CERTIFICATE_BASE64 }}
  255. DEVELOPER_ID_CERTIFICATE_PASSWORD: ${{ secrets.DEVELOPER_ID_CERTIFICATE_PASSWORD }}
  256. CODESIGN_IDENTITY: ${{ secrets.CODESIGN_IDENTITY }}
  257. - name: Create package (amd64)
  258. run: |
  259. go run build.go -goarch amd64 zip
  260. env:
  261. CGO_ENABLED: "1"
  262. - name: Create package (arm64 cross)
  263. run: |
  264. cat <<EOT > xgo.sh
  265. #!/bin/bash
  266. CGO_ENABLED=1 \
  267. CGO_CFLAGS="-target arm64-apple-macos10.15" \
  268. CGO_LDFLAGS="-target arm64-apple-macos10.15" \
  269. go "\$@"
  270. EOT
  271. chmod 755 xgo.sh
  272. go run build.go -gocmd ./xgo.sh -goarch arm64 zip
  273. env:
  274. CGO_ENABLED: "1"
  275. - name: Create package (universal)
  276. run: |
  277. rm -rf _tmp
  278. mkdir _tmp
  279. pushd _tmp
  280. unzip ../syncthing-macos-amd64-*.zip
  281. unzip ../syncthing-macos-arm64-*.zip
  282. lipo -create syncthing-macos-amd64-*/syncthing syncthing-macos-arm64-*/syncthing -o syncthing
  283. amd64=(syncthing-macos-amd64-*)
  284. universal="${amd64/amd64/universal}"
  285. mv "$amd64" "$universal"
  286. mv syncthing "$universal"
  287. zip -r "../$universal.zip" "$universal"
  288. - name: Archive artifacts
  289. uses: actions/upload-artifact@v4
  290. with:
  291. name: packages-macos
  292. path: syncthing-*.zip
  293. notarize-macos:
  294. name: Notarize for macOS
  295. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref == 'refs/heads/release' || startsWith(github.ref, 'refs/heads/release-'))
  296. environment: signing
  297. needs:
  298. - package-macos
  299. - basics
  300. runs-on: macos-latest
  301. steps:
  302. - name: Download artifacts
  303. uses: actions/download-artifact@v4
  304. with:
  305. name: packages-macos
  306. - name: Notarize binaries
  307. run: |
  308. APPSTORECONNECT_API_KEY_PATH="$RUNNER_TEMP/apikey.p8"
  309. echo "$APPSTORECONNECT_API_KEY" | base64 -d -o "$APPSTORECONNECT_API_KEY_PATH"
  310. for file in syncthing-macos-*.zip ; do
  311. xcrun notarytool submit \
  312. -k "$APPSTORECONNECT_API_KEY_PATH" \
  313. -d "$APPSTORECONNECT_API_KEY_ID" \
  314. -i "$APPSTORECONNECT_API_KEY_ISSUER" \
  315. $file
  316. done
  317. env:
  318. APPSTORECONNECT_API_KEY: ${{ secrets.APPSTORECONNECT_API_KEY }}
  319. APPSTORECONNECT_API_KEY_ID: ${{ secrets.APPSTORECONNECT_API_KEY_ID }}
  320. APPSTORECONNECT_API_KEY_ISSUER: ${{ secrets.APPSTORECONNECT_API_KEY_ISSUER }}
  321. #
  322. # Cross compile other unixes
  323. #
  324. package-cross:
  325. name: Package cross compiled
  326. runs-on: ubuntu-latest
  327. steps:
  328. - uses: actions/checkout@v4
  329. with:
  330. fetch-depth: 0
  331. - uses: actions/setup-go@v5
  332. with:
  333. go-version: ${{ env.GO_VERSION }}
  334. cache: false
  335. check-latest: true
  336. - name: Get actual Go version
  337. run: |
  338. go version
  339. echo "GO_VERSION=$(go version | sed 's#^.*go##;s# .*##')" >> $GITHUB_ENV
  340. - uses: actions/cache@v4
  341. with:
  342. path: |
  343. ~/.cache/go-build
  344. ~/go/pkg/mod
  345. key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-cross-${{ hashFiles('**/go.sum') }}
  346. - name: Create packages
  347. run: |
  348. platforms=$(go tool dist list \
  349. | grep -v aix/ppc64 \
  350. | grep -v android/ \
  351. | grep -v darwin/ \
  352. | grep -v ios/ \
  353. | grep -v js/ \
  354. | grep -v linux/ \
  355. | grep -v nacl/ \
  356. | grep -v plan9/ \
  357. | grep -v windows/ \
  358. | grep -v /wasm \
  359. )
  360. # Build for each platform with errors silenced, because we expect
  361. # some oddball platforms to fail. This avoids a bunch of errors in
  362. # the GitHub Actions output, instead summarizing each build
  363. # failure as a warning.
  364. for plat in $platforms; do
  365. goos="${plat%/*}"
  366. goarch="${plat#*/}"
  367. echo "::group ::$plat"
  368. if ! go run build.go -goos "$goos" -goarch "$goarch" tar 2>/dev/null; then
  369. echo "::warning ::Failed to build for $plat"
  370. fi
  371. echo "::endgroup::"
  372. done
  373. env:
  374. CGO_ENABLED: "0"
  375. - name: Archive artifacts
  376. uses: actions/upload-artifact@v4
  377. with:
  378. name: packages-other
  379. path: syncthing-*.tar.gz
  380. #
  381. # Source
  382. #
  383. package-source:
  384. name: Package source code
  385. runs-on: ubuntu-latest
  386. steps:
  387. - uses: actions/checkout@v4
  388. with:
  389. fetch-depth: 0
  390. - uses: actions/setup-go@v5
  391. with:
  392. go-version: ${{ env.GO_VERSION }}
  393. cache: false
  394. check-latest: true
  395. - name: Package source
  396. run: |
  397. version=$(go run build.go version)
  398. echo "$version" > RELEASE
  399. go mod vendor
  400. go run build.go assets
  401. cd ..
  402. tar c -z -f "syncthing-source-$version.tar.gz" \
  403. --exclude .git \
  404. syncthing
  405. mv "syncthing-source-$version.tar.gz" syncthing
  406. - name: Archive artifacts
  407. uses: actions/upload-artifact@v4
  408. with:
  409. name: packages-source
  410. path: syncthing-source-*.tar.gz
  411. #
  412. # Sign binaries for auto upgrade, generate ASC signature files
  413. #
  414. sign-for-upgrade:
  415. name: Sign for upgrade
  416. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref == 'refs/heads/release' || startsWith(github.ref, 'refs/heads/release-'))
  417. environment: signing
  418. needs:
  419. - basics
  420. - package-windows
  421. - package-linux
  422. - package-macos
  423. - package-cross
  424. - package-source
  425. runs-on: ubuntu-latest
  426. steps:
  427. - uses: actions/checkout@v4
  428. with:
  429. fetch-depth: 0
  430. - uses: actions/checkout@v4
  431. with:
  432. repository: syncthing/release-tools
  433. path: tools
  434. fetch-depth: 0
  435. - name: Download artifacts
  436. uses: actions/download-artifact@v4
  437. - uses: actions/setup-go@v5
  438. with:
  439. go-version: ${{ env.GO_VERSION }}
  440. cache: false
  441. check-latest: true
  442. - name: Install signing tool
  443. run: |
  444. go install ./cmd/dev/stsigtool
  445. - name: Sign archives
  446. run: |
  447. export PRIVATE_KEY="$RUNNER_TEMP/privkey.pem"
  448. export PATH="$PATH:$(go env GOPATH)/bin"
  449. echo "$STSIGTOOL_PRIVATE_KEY" | base64 -d > "$PRIVATE_KEY"
  450. mkdir packages
  451. mv packages-*/* packages
  452. pushd packages
  453. "$GITHUB_WORKSPACE/tools/sign-only"
  454. rm -f "$PRIVATE_KEY"
  455. env:
  456. STSIGTOOL_PRIVATE_KEY: ${{ secrets.STSIGTOOL_PRIVATE_KEY }}
  457. - name: Create and sign .asc files
  458. run: |
  459. sudo apt update
  460. sudo apt -y install gnupg
  461. export SIGNING_KEY="$RUNNER_TEMP/gpg-secret.asc"
  462. echo "$GNUPG_SIGNING_KEY_BASE64" | base64 -d > "$SIGNING_KEY"
  463. gpg --import < "$SIGNING_KEY"
  464. pushd packages
  465. files=(*.tar.gz *.zip)
  466. sha1sum "${files[@]}" | gpg --clearsign > sha1sum.txt.asc
  467. sha256sum "${files[@]}" | gpg --clearsign > sha256sum.txt.asc
  468. gpg --sign --armour --detach syncthing-source-*.tar.gz
  469. popd
  470. rm -f "$SIGNING_KEY" .gnupg
  471. env:
  472. GNUPG_SIGNING_KEY_BASE64: ${{ secrets.GNUPG_SIGNING_KEY_BASE64 }}
  473. - name: Archive artifacts
  474. uses: actions/upload-artifact@v4
  475. with:
  476. name: packages-signed
  477. path: packages/*
  478. #
  479. # Debian
  480. #
  481. package-debian:
  482. name: Package for Debian
  483. runs-on: ubuntu-latest
  484. steps:
  485. - uses: actions/checkout@v4
  486. with:
  487. fetch-depth: 0
  488. - uses: actions/setup-go@v5
  489. with:
  490. go-version: ${{ env.GO_VERSION }}
  491. cache: false
  492. check-latest: true
  493. - name: Get actual Go version
  494. run: |
  495. go version
  496. echo "GO_VERSION=$(go version | sed 's#^.*go##;s# .*##')" >> $GITHUB_ENV
  497. - uses: ruby/setup-ruby@v1
  498. with:
  499. ruby-version: '3.0'
  500. - name: Install fpm
  501. run: |
  502. gem install fpm
  503. - uses: actions/cache@v4
  504. with:
  505. path: |
  506. ~/.cache/go-build
  507. ~/go/pkg/mod
  508. key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-debian-${{ hashFiles('**/go.sum') }}
  509. - name: Package for Debian
  510. run: |
  511. for arch in amd64 i386 armhf armel arm64 ; do
  512. go run build.go -no-upgrade -installsuffix=no-upgrade -goarch "$arch" deb
  513. done
  514. env:
  515. BUILD_USER: debian
  516. - name: Archive artifacts
  517. uses: actions/upload-artifact@v4
  518. with:
  519. name: debian-packages
  520. path: "*.deb"
  521. #
  522. # Nightlies
  523. #
  524. publish-nightly:
  525. name: Publish nightly build
  526. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && startsWith(github.ref, 'refs/heads/release-nightly')
  527. environment: signing
  528. needs:
  529. - sign-for-upgrade
  530. - notarize-macos
  531. runs-on: ubuntu-latest
  532. steps:
  533. - uses: actions/checkout@v4
  534. with:
  535. repository: syncthing/release-tools
  536. path: tools
  537. fetch-depth: 0
  538. - name: Download artifacts
  539. uses: actions/download-artifact@v4
  540. with:
  541. name: packages-signed
  542. path: packages
  543. - uses: actions/setup-go@v5
  544. with:
  545. go-version: ${{ env.GO_VERSION }}
  546. cache: false
  547. check-latest: true
  548. - name: Create release json
  549. run: |
  550. cd packages
  551. "$GITHUB_WORKSPACE/tools/generate-release-json" "$BASE_URL" > nightly.json
  552. env:
  553. BASE_URL: ${{ secrets.NIGHTLY_BASE_URL }}
  554. - name: Push artifacts
  555. uses: docker://docker.io/rclone/rclone:latest
  556. env:
  557. RCLONE_CONFIG_OBJSTORE_TYPE: s3
  558. RCLONE_CONFIG_OBJSTORE_PROVIDER: ${{ secrets.S3_PROVIDER }}
  559. RCLONE_CONFIG_OBJSTORE_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
  560. RCLONE_CONFIG_OBJSTORE_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
  561. RCLONE_CONFIG_OBJSTORE_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
  562. RCLONE_CONFIG_OBJSTORE_REGION: ${{ secrets.S3_REGION }}
  563. RCLONE_CONFIG_OBJSTORE_ACL: public-read
  564. with:
  565. args: sync packages objstore:${{ secrets.S3_BUCKET }}/nightly
  566. #
  567. # Push release artifacts to Spaces
  568. #
  569. publish-release-files:
  570. name: Publish release files
  571. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/release'
  572. environment: signing
  573. needs:
  574. - sign-for-upgrade
  575. - package-debian
  576. runs-on: ubuntu-latest
  577. steps:
  578. - uses: actions/checkout@v4
  579. with:
  580. fetch-depth: 0
  581. - name: Download signed packages
  582. uses: actions/download-artifact@v4
  583. with:
  584. name: packages-signed
  585. path: packages
  586. - name: Download debian packages
  587. uses: actions/download-artifact@v4
  588. with:
  589. name: debian-packages
  590. path: packages
  591. - uses: actions/setup-go@v5
  592. with:
  593. go-version: ${{ env.GO_VERSION }}
  594. cache: false
  595. check-latest: true
  596. - name: Set version
  597. run: |
  598. version=$(go run build.go version)
  599. echo "VERSION=$version" >> $GITHUB_ENV
  600. - name: Push to object store (${{ env.VERSION }})
  601. uses: docker://docker.io/rclone/rclone:latest
  602. env:
  603. RCLONE_CONFIG_OBJSTORE_TYPE: s3
  604. RCLONE_CONFIG_OBJSTORE_PROVIDER: ${{ secrets.S3_PROVIDER }}
  605. RCLONE_CONFIG_OBJSTORE_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
  606. RCLONE_CONFIG_OBJSTORE_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
  607. RCLONE_CONFIG_OBJSTORE_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
  608. RCLONE_CONFIG_OBJSTORE_REGION: ${{ secrets.S3_REGION }}
  609. RCLONE_CONFIG_OBJSTORE_ACL: public-read
  610. with:
  611. args: sync packages objstore:${{ secrets.S3_BUCKET }}/release/${{ env.VERSION }}
  612. - name: Push to object store (latest)
  613. uses: docker://docker.io/rclone/rclone:latest
  614. env:
  615. RCLONE_CONFIG_OBJSTORE_TYPE: s3
  616. RCLONE_CONFIG_OBJSTORE_PROVIDER: ${{ secrets.S3_PROVIDER }}
  617. RCLONE_CONFIG_OBJSTORE_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
  618. RCLONE_CONFIG_OBJSTORE_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
  619. RCLONE_CONFIG_OBJSTORE_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
  620. RCLONE_CONFIG_OBJSTORE_REGION: ${{ secrets.S3_REGION }}
  621. RCLONE_CONFIG_OBJSTORE_ACL: public-read
  622. with:
  623. args: sync objstore:${{ secrets.S3_BUCKET }}/release/${{ env.VERSION }} objstore:${{ secrets.S3_BUCKET }}/release/latest
  624. #
  625. # Build and push to Docker Hub
  626. #
  627. docker-syncthing:
  628. name: Build and push Docker images
  629. runs-on: ubuntu-latest
  630. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/infrastructure' || startsWith(github.ref, 'refs/heads/release-'))
  631. environment: docker
  632. strategy:
  633. matrix:
  634. pkg:
  635. - syncthing
  636. - strelaysrv
  637. - stdiscosrv
  638. include:
  639. - pkg: syncthing
  640. dockerfile: Dockerfile
  641. image: syncthing/syncthing
  642. - pkg: strelaysrv
  643. dockerfile: Dockerfile.strelaysrv
  644. image: syncthing/relaysrv
  645. - pkg: stdiscosrv
  646. dockerfile: Dockerfile.stdiscosrv
  647. image: syncthing/discosrv
  648. steps:
  649. - uses: actions/checkout@v4
  650. with:
  651. fetch-depth: 0
  652. - uses: actions/setup-go@v5
  653. with:
  654. go-version: ${{ env.GO_VERSION }}
  655. cache: false
  656. check-latest: true
  657. - name: Get actual Go version
  658. run: |
  659. go version
  660. echo "GO_VERSION=$(go version | sed 's#^.*go##;s# .*##')" >> $GITHUB_ENV
  661. - uses: actions/cache@v4
  662. with:
  663. path: |
  664. ~/.cache/go-build
  665. ~/go/pkg/mod
  666. key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-docker-${{ matrix.pkg }}-${{ hashFiles('**/go.sum') }}
  667. - name: Build binaries
  668. run: |
  669. for arch in amd64 arm64 arm; do
  670. go run build.go -goos linux -goarch "$arch" -no-upgrade build ${{ matrix.pkg }}
  671. mv ${{ matrix.pkg }} ${{ matrix.pkg }}-linux-"$arch"
  672. done
  673. env:
  674. CGO_ENABLED: "0"
  675. BUILD_USER: docker
  676. - name: Check if we will be able to push images
  677. run: |
  678. if [[ "${{ secrets.DOCKERHUB_TOKEN }}" != "" ]]; then
  679. echo "DOCKER_PUSH=true" >> $GITHUB_ENV;
  680. fi
  681. - name: Login to Docker Hub
  682. uses: docker/login-action@v3
  683. if: env.DOCKER_PUSH == 'true'
  684. with:
  685. username: ${{ secrets.DOCKERHUB_USERNAME }}
  686. password: ${{ secrets.DOCKERHUB_TOKEN }}
  687. - name: Set up Docker Buildx
  688. uses: docker/setup-buildx-action@v3
  689. - name: Set version tags
  690. run: |
  691. version=$(go run build.go version)
  692. version=${version#v}
  693. if [[ $version == @([0-9]|[0-9][0-9]).@([0-9]|[0-9][0-9]).@([0-9]|[0-9][0-9]) ]] ; then
  694. echo Release version, pushing to :latest and version tags
  695. major=${version%.*.*}
  696. minor=${version%.*}
  697. tags=${{ matrix.image }}:$version,${{ matrix.image }}:$major,${{ matrix.image }}:$minor,${{ matrix.image }}:latest
  698. elif [[ $version == *-rc.@([0-9]|[0-9][0-9]) ]] ; then
  699. echo Release candidate, pushing to :rc
  700. tags=${{ matrix.image }}:rc
  701. else
  702. echo Development version, pushing to :edge
  703. tags=${{ matrix.image }}:edge
  704. fi
  705. echo "DOCKER_TAGS=$tags" >> $GITHUB_ENV
  706. echo "VERSION=$version" >> $GITHUB_ENV
  707. - name: Build and push Docker image
  708. uses: docker/build-push-action@v5
  709. with:
  710. context: .
  711. file: ${{ matrix.dockerfile }}
  712. platforms: linux/amd64,linux/arm64,linux/arm/7
  713. push: ${{ env.DOCKER_PUSH == 'true' }}
  714. tags: ${{ env.DOCKER_TAGS }}
  715. labels: |
  716. org.opencontainers.image.version=${{ env.VERSION }}
  717. org.opencontainers.image.revision=${{ github.sha }}
  718. #
  719. # Check for known vulnerabilities in Go dependencies
  720. #
  721. govulncheck:
  722. runs-on: ubuntu-latest
  723. name: Run govulncheck
  724. steps:
  725. - uses: actions/checkout@v4
  726. - uses: actions/setup-go@v5
  727. with:
  728. go-version: ${{ env.GO_VERSION }}
  729. cache: false
  730. check-latest: true
  731. - name: run govulncheck
  732. run: |
  733. go run build.go assets
  734. go install golang.org/x/vuln/cmd/govulncheck@latest
  735. govulncheck ./...