build-syncthing.yaml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  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.22.3"
  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.21.7", "~1.22.3"]
  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/goversioninfo@v1.4.0
  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: syncthing-linux-*.tar.gz
  206. #
  207. # macOS
  208. #
  209. package-macos:
  210. name: Package for macOS
  211. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref == 'refs/heads/release' || startsWith(github.ref, 'refs/heads/release-'))
  212. environment: signing
  213. runs-on: macos-latest
  214. steps:
  215. - uses: actions/checkout@v4
  216. with:
  217. fetch-depth: 0
  218. - uses: actions/setup-go@v5
  219. with:
  220. go-version: ${{ env.GO_VERSION }}
  221. cache: false
  222. check-latest: true
  223. - name: Get actual Go version
  224. run: |
  225. go version
  226. echo "GO_VERSION=$(go version | sed 's#^.*go##;s# .*##')" >> $GITHUB_ENV
  227. - uses: actions/cache@v4
  228. with:
  229. path: |
  230. ~/.cache/go-build
  231. ~/go/pkg/mod
  232. key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-package-${{ hashFiles('**/go.sum') }}
  233. - name: Import signing certificate
  234. run: |
  235. # Set up a run-specific keychain, making it available for the
  236. # `codesign` tool.
  237. umask 066
  238. KEYCHAIN_PATH=$RUNNER_TEMP/codesign.keychain
  239. KEYCHAIN_PASSWORD=$(uuidgen)
  240. security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
  241. security default-keychain -s "$KEYCHAIN_PATH"
  242. security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
  243. security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
  244. # Import the certificate
  245. CERTIFICATE_PATH=$RUNNER_TEMP/codesign.p12
  246. echo "$DEVELOPER_ID_CERTIFICATE_BASE64" | base64 -d -o "$CERTIFICATE_PATH"
  247. security import "$CERTIFICATE_PATH" -k "$KEYCHAIN_PATH" -P "$DEVELOPER_ID_CERTIFICATE_PASSWORD" -T /usr/bin/codesign -T /usr/bin/productsign
  248. security set-key-partition-list -S apple-tool:,apple: -s -k actions "$KEYCHAIN_PATH"
  249. # Set the codesign identity for following steps
  250. echo "CODESIGN_IDENTITY=$CODESIGN_IDENTITY" >> $GITHUB_ENV
  251. env:
  252. DEVELOPER_ID_CERTIFICATE_BASE64: ${{ secrets.DEVELOPER_ID_CERTIFICATE_BASE64 }}
  253. DEVELOPER_ID_CERTIFICATE_PASSWORD: ${{ secrets.DEVELOPER_ID_CERTIFICATE_PASSWORD }}
  254. CODESIGN_IDENTITY: ${{ secrets.CODESIGN_IDENTITY }}
  255. - name: Create package (amd64)
  256. run: |
  257. go run build.go -goarch amd64 zip
  258. env:
  259. CGO_ENABLED: "1"
  260. - name: Create package (arm64 cross)
  261. run: |
  262. cat <<EOT > xgo.sh
  263. #!/bin/bash
  264. CGO_ENABLED=1 \
  265. CGO_CFLAGS="-target arm64-apple-macos10.15" \
  266. CGO_LDFLAGS="-target arm64-apple-macos10.15" \
  267. go "\$@"
  268. EOT
  269. chmod 755 xgo.sh
  270. go run build.go -gocmd ./xgo.sh -goarch arm64 zip
  271. env:
  272. CGO_ENABLED: "1"
  273. - name: Create package (universal)
  274. run: |
  275. rm -rf _tmp
  276. mkdir _tmp
  277. pushd _tmp
  278. unzip ../syncthing-macos-amd64-*.zip
  279. unzip ../syncthing-macos-arm64-*.zip
  280. lipo -create syncthing-macos-amd64-*/syncthing syncthing-macos-arm64-*/syncthing -o syncthing
  281. amd64=(syncthing-macos-amd64-*)
  282. universal="${amd64/amd64/universal}"
  283. mv "$amd64" "$universal"
  284. mv syncthing "$universal"
  285. zip -r "../$universal.zip" "$universal"
  286. - name: Archive artifacts
  287. uses: actions/upload-artifact@v4
  288. with:
  289. name: packages-macos
  290. path: syncthing-*.zip
  291. notarize-macos:
  292. name: Notarize for macOS
  293. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref == 'refs/heads/release' || startsWith(github.ref, 'refs/heads/release-'))
  294. environment: signing
  295. needs:
  296. - package-macos
  297. - basics
  298. runs-on: macos-latest
  299. steps:
  300. - name: Download artifacts
  301. uses: actions/download-artifact@v4
  302. with:
  303. name: packages-macos
  304. - name: Notarize binaries
  305. run: |
  306. APPSTORECONNECT_API_KEY_PATH="$RUNNER_TEMP/apikey.p8"
  307. echo "$APPSTORECONNECT_API_KEY" | base64 -d -o "$APPSTORECONNECT_API_KEY_PATH"
  308. for file in syncthing-macos-*.zip ; do
  309. xcrun notarytool submit \
  310. -k "$APPSTORECONNECT_API_KEY_PATH" \
  311. -d "$APPSTORECONNECT_API_KEY_ID" \
  312. -i "$APPSTORECONNECT_API_KEY_ISSUER" \
  313. $file
  314. done
  315. env:
  316. APPSTORECONNECT_API_KEY: ${{ secrets.APPSTORECONNECT_API_KEY }}
  317. APPSTORECONNECT_API_KEY_ID: ${{ secrets.APPSTORECONNECT_API_KEY_ID }}
  318. APPSTORECONNECT_API_KEY_ISSUER: ${{ secrets.APPSTORECONNECT_API_KEY_ISSUER }}
  319. #
  320. # Cross compile other unixes
  321. #
  322. package-cross:
  323. name: Package cross compiled
  324. runs-on: ubuntu-latest
  325. steps:
  326. - uses: actions/checkout@v4
  327. with:
  328. fetch-depth: 0
  329. - uses: actions/setup-go@v5
  330. with:
  331. go-version: ${{ env.GO_VERSION }}
  332. cache: false
  333. check-latest: true
  334. - name: Get actual Go version
  335. run: |
  336. go version
  337. echo "GO_VERSION=$(go version | sed 's#^.*go##;s# .*##')" >> $GITHUB_ENV
  338. - uses: actions/cache@v4
  339. with:
  340. path: |
  341. ~/.cache/go-build
  342. ~/go/pkg/mod
  343. key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-cross-${{ hashFiles('**/go.sum') }}
  344. - name: Create packages
  345. run: |
  346. platforms=$(go tool dist list \
  347. | grep -v aix/ppc64 \
  348. | grep -v android/ \
  349. | grep -v darwin/ \
  350. | grep -v ios/ \
  351. | grep -v js/ \
  352. | grep -v linux/ \
  353. | grep -v nacl/ \
  354. | grep -v plan9/ \
  355. | grep -v windows/ \
  356. | grep -v /wasm \
  357. )
  358. # Build for each platform with errors silenced, because we expect
  359. # some oddball platforms to fail. This avoids a bunch of errors in
  360. # the GitHub Actions output, instead summarizing each build
  361. # failure as a warning.
  362. for plat in $platforms; do
  363. goos="${plat%/*}"
  364. goarch="${plat#*/}"
  365. echo "::group ::$plat"
  366. if ! go run build.go -goos "$goos" -goarch "$goarch" tar 2>/dev/null; then
  367. echo "::warning ::Failed to build for $plat"
  368. fi
  369. echo "::endgroup::"
  370. done
  371. env:
  372. CGO_ENABLED: "0"
  373. - name: Archive artifacts
  374. uses: actions/upload-artifact@v4
  375. with:
  376. name: packages-other
  377. path: syncthing-*.tar.gz
  378. #
  379. # Source
  380. #
  381. package-source:
  382. name: Package source code
  383. runs-on: ubuntu-latest
  384. steps:
  385. - uses: actions/checkout@v4
  386. with:
  387. fetch-depth: 0
  388. - uses: actions/setup-go@v5
  389. with:
  390. go-version: ${{ env.GO_VERSION }}
  391. cache: false
  392. check-latest: true
  393. - name: Package source
  394. run: |
  395. version=$(go run build.go version)
  396. echo "$version" > RELEASE
  397. go mod vendor
  398. go run build.go assets
  399. cd ..
  400. tar c -z -f "syncthing-source-$version.tar.gz" \
  401. --exclude .git \
  402. syncthing
  403. mv "syncthing-source-$version.tar.gz" syncthing
  404. - name: Archive artifacts
  405. uses: actions/upload-artifact@v4
  406. with:
  407. name: packages-source
  408. path: syncthing-source-*.tar.gz
  409. #
  410. # Sign binaries for auto upgrade, generate ASC signature files
  411. #
  412. sign-for-upgrade:
  413. name: Sign for upgrade
  414. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref == 'refs/heads/release' || startsWith(github.ref, 'refs/heads/release-'))
  415. environment: signing
  416. needs:
  417. - basics
  418. - package-windows
  419. - package-linux
  420. - package-macos
  421. - package-cross
  422. - package-source
  423. runs-on: ubuntu-latest
  424. steps:
  425. - uses: actions/checkout@v4
  426. with:
  427. fetch-depth: 0
  428. - uses: actions/checkout@v4
  429. with:
  430. repository: syncthing/release-tools
  431. path: tools
  432. fetch-depth: 0
  433. - name: Download artifacts
  434. uses: actions/download-artifact@v4
  435. - uses: actions/setup-go@v5
  436. with:
  437. go-version: ${{ env.GO_VERSION }}
  438. cache: false
  439. check-latest: true
  440. - name: Install signing tool
  441. run: |
  442. go install ./cmd/stsigtool
  443. - name: Sign archives
  444. run: |
  445. export PRIVATE_KEY="$RUNNER_TEMP/privkey.pem"
  446. export PATH="$PATH:$(go env GOPATH)/bin"
  447. echo "$STSIGTOOL_PRIVATE_KEY" | base64 -d > "$PRIVATE_KEY"
  448. mkdir packages
  449. mv packages-*/* packages
  450. pushd packages
  451. "$GITHUB_WORKSPACE/tools/sign-only"
  452. rm -f "$PRIVATE_KEY"
  453. env:
  454. STSIGTOOL_PRIVATE_KEY: ${{ secrets.STSIGTOOL_PRIVATE_KEY }}
  455. - name: Create and sign .asc files
  456. run: |
  457. sudo apt update
  458. sudo apt -y install gnupg
  459. export SIGNING_KEY="$RUNNER_TEMP/gpg-secret.asc"
  460. echo "$GNUPG_SIGNING_KEY_BASE64" | base64 -d > "$SIGNING_KEY"
  461. gpg --import < "$SIGNING_KEY"
  462. pushd packages
  463. files=(*.tar.gz *.zip)
  464. sha1sum "${files[@]}" | gpg --clearsign > sha1sum.txt.asc
  465. sha256sum "${files[@]}" | gpg --clearsign > sha256sum.txt.asc
  466. gpg --sign --armour --detach syncthing-source-*.tar.gz
  467. popd
  468. rm -f "$SIGNING_KEY" .gnupg
  469. env:
  470. GNUPG_SIGNING_KEY_BASE64: ${{ secrets.GNUPG_SIGNING_KEY_BASE64 }}
  471. - name: Archive artifacts
  472. uses: actions/upload-artifact@v4
  473. with:
  474. name: packages-signed
  475. path: packages/*
  476. #
  477. # Debian
  478. #
  479. package-debian:
  480. name: Package for Debian
  481. runs-on: ubuntu-latest
  482. steps:
  483. - uses: actions/checkout@v4
  484. with:
  485. fetch-depth: 0
  486. - uses: actions/setup-go@v5
  487. with:
  488. go-version: ${{ env.GO_VERSION }}
  489. cache: false
  490. check-latest: true
  491. - name: Get actual Go version
  492. run: |
  493. go version
  494. echo "GO_VERSION=$(go version | sed 's#^.*go##;s# .*##')" >> $GITHUB_ENV
  495. - uses: ruby/setup-ruby@v1
  496. with:
  497. ruby-version: '3.0'
  498. - name: Install fpm
  499. run: |
  500. gem install fpm
  501. - uses: actions/cache@v4
  502. with:
  503. path: |
  504. ~/.cache/go-build
  505. ~/go/pkg/mod
  506. key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-debian-${{ hashFiles('**/go.sum') }}
  507. - name: Package for Debian
  508. run: |
  509. for arch in amd64 i386 armhf armel arm64 ; do
  510. go run build.go -no-upgrade -installsuffix=no-upgrade -goarch "$arch" deb
  511. done
  512. env:
  513. BUILD_USER: debian
  514. - name: Archive artifacts
  515. uses: actions/upload-artifact@v4
  516. with:
  517. name: debian-packages
  518. path: "*.deb"
  519. #
  520. # Nightlies
  521. #
  522. publish-nightly:
  523. name: Publish nightly build
  524. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && startsWith(github.ref, 'refs/heads/release-nightly')
  525. environment: signing
  526. needs:
  527. - sign-for-upgrade
  528. - notarize-macos
  529. runs-on: ubuntu-latest
  530. steps:
  531. - uses: actions/checkout@v4
  532. with:
  533. repository: syncthing/release-tools
  534. path: tools
  535. fetch-depth: 0
  536. - name: Download artifacts
  537. uses: actions/download-artifact@v4
  538. with:
  539. name: packages-signed
  540. path: packages
  541. - uses: actions/setup-go@v5
  542. with:
  543. go-version: ${{ env.GO_VERSION }}
  544. cache: false
  545. check-latest: true
  546. - name: Create release json
  547. run: |
  548. cd packages
  549. "$GITHUB_WORKSPACE/tools/generate-release-json" "$BASE_URL" > nightly.json
  550. env:
  551. BASE_URL: ${{ secrets.NIGHTLY_BASE_URL }}
  552. - name: Push artifacts
  553. uses: docker://docker.io/rclone/rclone:latest
  554. env:
  555. RCLONE_CONFIG_OBJSTORE_TYPE: s3
  556. RCLONE_CONFIG_OBJSTORE_PROVIDER: ${{ secrets.S3_PROVIDER }}
  557. RCLONE_CONFIG_OBJSTORE_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
  558. RCLONE_CONFIG_OBJSTORE_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
  559. RCLONE_CONFIG_OBJSTORE_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
  560. RCLONE_CONFIG_OBJSTORE_REGION: ${{ secrets.S3_REGION }}
  561. RCLONE_CONFIG_OBJSTORE_ACL: public-read
  562. with:
  563. args: sync packages objstore:${{ secrets.S3_BUCKET }}/nightly
  564. #
  565. # Push release artifacts to Spaces
  566. #
  567. publish-release-files:
  568. name: Publish release files
  569. if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/release'
  570. environment: signing
  571. needs:
  572. - sign-for-upgrade
  573. - package-debian
  574. runs-on: ubuntu-latest
  575. steps:
  576. - uses: actions/checkout@v4
  577. with:
  578. fetch-depth: 0
  579. - name: Download signed packages
  580. uses: actions/download-artifact@v4
  581. with:
  582. name: packages-signed
  583. path: packages
  584. - name: Download debian packages
  585. uses: actions/download-artifact@v4
  586. with:
  587. name: debian-packages
  588. path: packages
  589. - uses: actions/setup-go@v5
  590. with:
  591. go-version: ${{ env.GO_VERSION }}
  592. cache: false
  593. check-latest: true
  594. - name: Set version
  595. run: |
  596. version=$(go run build.go version)
  597. echo "VERSION=$version" >> $GITHUB_ENV
  598. - name: Push to object store (${{ env.VERSION }})
  599. uses: docker://docker.io/rclone/rclone:latest
  600. env:
  601. RCLONE_CONFIG_OBJSTORE_TYPE: s3
  602. RCLONE_CONFIG_OBJSTORE_PROVIDER: ${{ secrets.S3_PROVIDER }}
  603. RCLONE_CONFIG_OBJSTORE_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
  604. RCLONE_CONFIG_OBJSTORE_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
  605. RCLONE_CONFIG_OBJSTORE_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
  606. RCLONE_CONFIG_OBJSTORE_REGION: ${{ secrets.S3_REGION }}
  607. RCLONE_CONFIG_OBJSTORE_ACL: public-read
  608. with:
  609. args: sync packages objstore:${{ secrets.S3_BUCKET }}/release/${{ env.VERSION }}
  610. - name: Push to object store (latest)
  611. uses: docker://docker.io/rclone/rclone:latest
  612. env:
  613. RCLONE_CONFIG_OBJSTORE_TYPE: s3
  614. RCLONE_CONFIG_OBJSTORE_PROVIDER: ${{ secrets.S3_PROVIDER }}
  615. RCLONE_CONFIG_OBJSTORE_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
  616. RCLONE_CONFIG_OBJSTORE_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
  617. RCLONE_CONFIG_OBJSTORE_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
  618. RCLONE_CONFIG_OBJSTORE_REGION: ${{ secrets.S3_REGION }}
  619. RCLONE_CONFIG_OBJSTORE_ACL: public-read
  620. with:
  621. args: sync objstore:${{ secrets.S3_BUCKET }}/release/${{ env.VERSION }} objstore:${{ secrets.S3_BUCKET }}/release/latest
  622. #
  623. # Build and push to Docker Hub
  624. #
  625. docker-syncthing:
  626. name: Build and push Docker images
  627. runs-on: ubuntu-latest
  628. 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-'))
  629. environment: docker
  630. strategy:
  631. matrix:
  632. pkg:
  633. - syncthing
  634. - strelaysrv
  635. - stdiscosrv
  636. include:
  637. - pkg: syncthing
  638. dockerfile: Dockerfile
  639. image: syncthing/syncthing
  640. - pkg: strelaysrv
  641. dockerfile: Dockerfile.strelaysrv
  642. image: syncthing/relaysrv
  643. - pkg: stdiscosrv
  644. dockerfile: Dockerfile.stdiscosrv
  645. image: syncthing/discosrv
  646. steps:
  647. - uses: actions/checkout@v4
  648. with:
  649. fetch-depth: 0
  650. - uses: actions/setup-go@v5
  651. with:
  652. go-version: ${{ env.GO_VERSION }}
  653. cache: false
  654. check-latest: true
  655. - name: Get actual Go version
  656. run: |
  657. go version
  658. echo "GO_VERSION=$(go version | sed 's#^.*go##;s# .*##')" >> $GITHUB_ENV
  659. - uses: actions/cache@v4
  660. with:
  661. path: |
  662. ~/.cache/go-build
  663. ~/go/pkg/mod
  664. key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-docker-${{ matrix.pkg }}-${{ hashFiles('**/go.sum') }}
  665. - name: Build binaries
  666. run: |
  667. for arch in amd64 arm64 arm; do
  668. go run build.go -goos linux -goarch "$arch" -no-upgrade build ${{ matrix.pkg }}
  669. mv ${{ matrix.pkg }} ${{ matrix.pkg }}-linux-"$arch"
  670. done
  671. env:
  672. CGO_ENABLED: "0"
  673. BUILD_USER: docker
  674. - name: Check if we will be able to push images
  675. run: |
  676. if [[ "${{ secrets.DOCKERHUB_TOKEN }}" != "" ]]; then
  677. echo "DOCKER_PUSH=true" >> $GITHUB_ENV;
  678. fi
  679. - name: Login to Docker Hub
  680. uses: docker/login-action@v3
  681. if: env.DOCKER_PUSH == 'true'
  682. with:
  683. username: ${{ secrets.DOCKERHUB_USERNAME }}
  684. password: ${{ secrets.DOCKERHUB_TOKEN }}
  685. - name: Set up Docker Buildx
  686. uses: docker/setup-buildx-action@v3
  687. - name: Set version tags
  688. run: |
  689. version=$(go run build.go version)
  690. version=${version#v}
  691. if [[ $version == @([0-9]|[0-9][0-9]).@([0-9]|[0-9][0-9]).@([0-9]|[0-9][0-9]) ]] ; then
  692. echo Release version, pushing to :latest and version tags
  693. major=${version%.*.*}
  694. minor=${version%.*}
  695. tags=${{ matrix.image }}:$version,${{ matrix.image }}:$major,${{ matrix.image }}:$minor,${{ matrix.image }}:latest
  696. elif [[ $version == *-rc.@([0-9]|[0-9][0-9]) ]] ; then
  697. echo Release candidate, pushing to :rc
  698. tags=${{ matrix.image }}:rc
  699. else
  700. echo Development version, pushing to :edge
  701. tags=${{ matrix.image }}:edge
  702. fi
  703. echo "DOCKER_TAGS=$tags" >> $GITHUB_ENV
  704. echo "VERSION=$version" >> $GITHUB_ENV
  705. - name: Build and push Docker image
  706. uses: docker/build-push-action@v5
  707. with:
  708. context: .
  709. file: ${{ matrix.dockerfile }}
  710. platforms: linux/amd64,linux/arm64,linux/arm/7
  711. push: ${{ env.DOCKER_PUSH == 'true' }}
  712. tags: ${{ env.DOCKER_TAGS }}
  713. labels: |
  714. org.opencontainers.image.version=${{ env.VERSION }}
  715. org.opencontainers.image.revision=${{ github.sha }}
  716. #
  717. # Check for known vulnerabilities in Go dependencies
  718. #
  719. govulncheck:
  720. runs-on: ubuntu-latest
  721. name: Run govulncheck
  722. steps:
  723. - uses: actions/checkout@v4
  724. - uses: actions/setup-go@v5
  725. with:
  726. go-version: ${{ env.GO_VERSION }}
  727. cache: false
  728. check-latest: true
  729. - name: run govulncheck
  730. run: |
  731. go run build.go assets
  732. go install golang.org/x/vuln/cmd/govulncheck@latest
  733. govulncheck ./...