build.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. name: Package-Build
  2. on: [push, pull_request]
  3. jobs:
  4. Lint:
  5. runs-on: ubuntu-24.04
  6. steps:
  7. - name: Checkout
  8. uses: actions/checkout@v3
  9. with:
  10. fetch-depth: 0
  11. - name: Installing Node
  12. uses: actions/[email protected]
  13. with:
  14. node-version: 22
  15. - name: Install deps
  16. run: |
  17. sudo apt-get update && sudo apt-get install -y libfontconfig1-dev
  18. npm i -g yarn
  19. cd app
  20. yarn
  21. cd ..
  22. rm app/node_modules/.yarn-integrity
  23. yarn
  24. - name: Build typings
  25. run: yarn run build:typings
  26. - name: Lint
  27. run: yarn run lint
  28. macOS-Build:
  29. runs-on: macos-15
  30. needs: Lint
  31. strategy:
  32. matrix:
  33. include:
  34. - arch: x86_64
  35. rust_triple: x86_64-apple-darwin
  36. - arch: arm64
  37. rust_triple: aarch64-apple-darwin
  38. fail-fast: false
  39. env:
  40. ARCH: ${{matrix.arch}}
  41. RUST_TARGET_TRIPLE: ${{matrix.rust_triple}}
  42. steps:
  43. - name: Checkout
  44. uses: actions/checkout@v3
  45. with:
  46. fetch-depth: 0
  47. - name: Installing Node
  48. uses: actions/[email protected]
  49. with:
  50. node-version: 22
  51. - run: rustup target add ${{matrix.rust_triple}}
  52. - name: Install deps
  53. run: |
  54. yarn --network-timeout 1000000
  55. env:
  56. ARCH: ${{matrix.arch}}
  57. - name: Webpack
  58. run: yarn run build
  59. - name: Prepackage plugins
  60. run: scripts/prepackage-plugins.mjs
  61. env:
  62. ARCH: ${{matrix.arch}}
  63. - run: sed -i '' 's/updateInfo = await/\/\/updateInfo = await/g' node_modules/app-builder-lib/out/targets/ArchiveTarget.js
  64. # Work around electron-builder beta bug
  65. - run: ln -s ../../node_modules/electron app/node_modules
  66. - name: Build and sign packages
  67. run: scripts/build-macos.mjs
  68. if: github.event_name == 'push' && (github.ref_protected || startsWith(github.ref, 'refs/tags'))
  69. env:
  70. ARCH: ${{matrix.arch}}
  71. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  72. KEYGEN_TOKEN: ${{ secrets.KEYGEN_TOKEN }}
  73. CSC_LINK: ${{ secrets.CSC_LINK }}
  74. CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
  75. APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
  76. APPSTORE_USERNAME: ${{ secrets.APPSTORE_USERNAME }}
  77. APPSTORE_PASSWORD: ${{ secrets.APPSTORE_PASSWORD }}
  78. USE_HARD_LINKS: false
  79. # DEBUG: electron-builder,electron-builder:*
  80. - name: Build packages without signing
  81. run: scripts/build-macos.mjs
  82. if: "! (github.event_name == 'push' && (github.ref_protected || startsWith(github.ref, 'refs/tags')))"
  83. env:
  84. ARCH: ${{matrix.arch}}
  85. # DEBUG: electron-builder,electron-builder:*
  86. - name: Upload symbols
  87. run: |
  88. sudo npm install -g @sentry/cli --unsafe-perm
  89. ./scripts/sentry-upload.mjs
  90. env:
  91. SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
  92. SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
  93. SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
  94. - name: Package artifacts
  95. run: |
  96. mkdir artifact-dmg
  97. mv dist/*.dmg artifact-dmg/
  98. mkdir artifact-zip
  99. mv dist/*.zip artifact-zip/
  100. - uses: actions/upload-artifact@master
  101. name: Upload DMG
  102. with:
  103. name: macOS .dmg (${{matrix.arch}})
  104. path: artifact-dmg
  105. - uses: actions/upload-artifact@master
  106. name: Upload ZIP
  107. with:
  108. name: macOS .zip (${{matrix.arch}})
  109. path: artifact-zip
  110. Linux-Build:
  111. runs-on: ${{matrix.os}}
  112. needs: Lint
  113. strategy:
  114. matrix:
  115. include:
  116. - build-arch: x64
  117. arch: amd64
  118. rust_triple: x86_64-unknown-linux-gnu
  119. os: ubuntu-24.04
  120. - build-arch: arm64
  121. arch: arm64
  122. rust_triple: aarch64-unknown-linux-gnu
  123. triplet: aarch64-linux-gnu-
  124. os: ubuntu-24.04-arm
  125. - build-arch: arm
  126. arch: armhf
  127. rust_triple: arm-unknown-linux-gnueabihf
  128. triplet: arm-linux-gnueabihf-
  129. os: ubuntu-24.04
  130. fail-fast: false
  131. env:
  132. CC: ${{matrix.triplet}}gcc
  133. CXX: ${{matrix.triplet}}g++
  134. ARCH: ${{matrix.build-arch}}
  135. npm_config_arch: ${{matrix.build-arch}}
  136. npm_config_target_arch: ${{matrix.build-arch}}
  137. RUST_TARGET_TRIPLE: ${{matrix.rust_triple}}
  138. steps:
  139. - name: Checkout
  140. uses: actions/checkout@v3
  141. with:
  142. fetch-depth: 0
  143. - name: Install Node
  144. uses: actions/[email protected]
  145. with:
  146. node-version: 22
  147. - name: Install FPM
  148. run: |
  149. sudo gem install fpm
  150. - run: rustup target add ${{matrix.rust_triple}}
  151. - name: Install dependencies
  152. run: |
  153. sudo apt-get update
  154. sudo apt-get install libfontconfig1-dev libarchive-tools zsh crossbuild-essential-${{matrix.arch}}
  155. - name: Setup tar to run as root
  156. run: sudo chmod u+s "$(command -v tar)"
  157. if: matrix.build-arch == 'arm'
  158. - name: Download cached sysroot
  159. uses: actions/cache@v3
  160. id: dl-cached-sysroot
  161. if: matrix.build-arch == 'arm'
  162. with:
  163. key: sysroot-${{matrix.build-arch}}
  164. path: /${{matrix.build-arch}}-sysroot
  165. - name: Setup crossbuild sysroot
  166. run: |
  167. sudo apt-get update -y && sudo apt-get install debootstrap qemu-user-static binfmt-support -y
  168. sudo qemu-debootstrap --include=libfontconfig1-dev,libsecret-1-dev,libnss3,libatk1.0-0,libatk-bridge2.0-0,libgdk-pixbuf2.0-0,libgtk-3-0,libgbm1 --variant=buildd --exclude=snapd --components=main,restricted,universe,multiverse --extractor=dpkg-deb --arch ${{matrix.arch}} bionic /${{matrix.build-arch}}-sysroot/ http://ports.ubuntu.com/ubuntu-ports/
  169. sudo find /${{matrix.build-arch}}-sysroot -type l -lname '/*' -exec sh -c 'file="$0"; dir=$(dirname "$file"); target=$(readlink "$0"); prefix=$(dirname "$dir" | sed 's@[^/]*@\.\.@g'); newtarget="$prefix$target"; ln -snf $newtarget $file' {} \; ;
  170. if: matrix.build-arch == 'arm' && steps.dl-cached-sysroot.outputs.cache-hit != 'true'
  171. - name: Setup env to use ${{matrix.build-arch}} sysroot
  172. run: |
  173. echo "CFLAGS=--sysroot=/${{matrix.build-arch}}-sysroot/" >> $GITHUB_ENV
  174. echo "CXXFLAGS=--sysroot=/${{matrix.build-arch}}-sysroot/" >> $GITHUB_ENV
  175. echo "LDFLAGS=--sysroot=/${{matrix.build-arch}}-sysroot/" >> $GITHUB_ENV
  176. [[ ${npm_config_arch} == 'arm' ]] && echo "npm_config_arch=armv7l" >> $GITHUB_ENV
  177. if [[ ${{matrix.arch}} == 'armhf' ]]; then
  178. echo "PKG_CONFIG_PATH=/${{matrix.build-arch}}-sysroot/usr/lib/pkgconfig/:/${{matrix.build-arch}}-sysroot/usr/lib/arm-linux-gnueabihf/pkgconfig/" >> $GITHUB_ENV
  179. elif [[ ${{matrix.arch}} == 'arm64' ]]; then
  180. echo "PKG_CONFIG_PATH=/${{matrix.build-arch}}-sysroot/usr/lib/pkgconfig/:/${{matrix.build-arch}}-sysroot/usr/lib/aarch64-linux-gnu/pkgconfig/" >> $GITHUB_ENV
  181. fi
  182. if: matrix.build-arch == 'arm'
  183. - name: Install npm_modules (native)
  184. run: |
  185. npm i -g yarn node-gyp
  186. yarn --network-timeout 1000000 --arch=${{matrix.build-arch}} --target-arch=${{matrix.build-arch}}
  187. - name: Webpack (${{matrix.arch}})
  188. run: yarn run build --arch=${{matrix.build-arch}} --target_arch=${{matrix.build-arch}}
  189. - name: Prepackage plugins (${{matrix.arch}})
  190. run: scripts/prepackage-plugins.mjs
  191. - name: Build packages (${{matrix.arch}})
  192. run: scripts/build-linux.mjs
  193. env:
  194. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  195. KEYGEN_TOKEN: ${{ secrets.KEYGEN_TOKEN }}
  196. USE_HARD_LINKS: false
  197. USE_SYSTEM_FPM: true
  198. # DEBUG: electron-builder,electron-builder:*
  199. - name: Build web resources (amd64 only)
  200. run: zsh -c 'tar czf tabby-web.tar.gz (tabby-*|web)/dist'
  201. if: matrix.build-arch == 'x64'
  202. - name: Upload symbols (amd64 only)
  203. run: |
  204. sudo npm install -g @sentry/cli --unsafe-perm
  205. ./scripts/sentry-upload.mjs
  206. if: matrix.build-arch == 'x64'
  207. env:
  208. SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
  209. SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
  210. SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
  211. - name: Upload packages to packagecloud.io
  212. uses: TykTechnologies/packagecloud-action@main
  213. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
  214. env:
  215. PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
  216. with:
  217. repo: 'eugeny/tabby'
  218. dir: 'dist'
  219. rpmvers: 'el/9 el/8 ol/6 ol/7'
  220. debvers: 'ubuntu/bionic ubuntu/focal ubuntu/hirsute ubuntu/impish ubuntu/jammy ubuntu/kinetic ubuntu/noble ubuntu/oracular debian/jessie debian/stretch debian/buster'
  221. - uses: actions/upload-artifact@master
  222. name: Upload AppImage (${{matrix.arch}})
  223. with:
  224. name: Linux AppImage (${{matrix.arch}})
  225. path: dist/*.AppImage
  226. - uses: actions/upload-artifact@master
  227. name: Upload DEB (${{matrix.arch}})
  228. with:
  229. name: Linux DEB (${{matrix.arch}})
  230. path: dist/*.deb
  231. - uses: actions/upload-artifact@master
  232. name: Upload RPM (${{matrix.arch}})
  233. with:
  234. name: Linux RPM (${{matrix.arch}})
  235. path: dist/*.rpm
  236. - uses: actions/upload-artifact@master
  237. name: Upload Pacman Package (${{matrix.arch}})
  238. with:
  239. name: Linux Pacman (${{matrix.arch}})
  240. path: dist/*.pacman
  241. - uses: actions/upload-artifact@master
  242. name: Upload Linux tarball (${{matrix.arch}})
  243. with:
  244. name: Linux tarball (${{matrix.arch}})
  245. path: dist/*.tar.gz
  246. - uses: actions/upload-artifact@master
  247. name: Upload web tarball (amd64 only)
  248. with:
  249. name: Web tarball
  250. path: tabby-web.tar.gz
  251. if: matrix.build-arch == 'x64'
  252. Windows-Build:
  253. runs-on: windows-latest
  254. needs: Lint
  255. strategy:
  256. matrix:
  257. include:
  258. - arch: x64
  259. rust_triple: x86_64-pc-windows-msvc
  260. - arch: arm64
  261. rust_triple: aarch64-pc-windows-msvc
  262. fail-fast: false
  263. env:
  264. RUST_TARGET_TRIPLE: ${{matrix.rust_triple}}
  265. ARCH: ${{matrix.arch}}
  266. steps:
  267. - name: Checkout
  268. uses: actions/checkout@v3
  269. with:
  270. fetch-depth: 0
  271. - name: Code signing with Software Trust Manager
  272. uses: digicert/[email protected]
  273. if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags'))
  274. - name: Installing Node
  275. uses: actions/[email protected]
  276. with:
  277. node-version: 22
  278. - run: npm i -g npx
  279. - run: rustup target add ${{matrix.rust_triple}}
  280. - name: Update node-gyp
  281. run: |
  282. npm install --global [email protected]
  283. npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
  284. - name: Build
  285. shell: powershell
  286. run: |
  287. npm i -g yar node-gyp
  288. yarn --network-timeout 1000000
  289. yarn run build
  290. node scripts/prepackage-plugins.mjs
  291. env:
  292. ARCH: ${{matrix.arch}}
  293. - name: Decode certificate
  294. if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags'))
  295. env:
  296. SM_CLIENT_CERT_FILE_B64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }}
  297. run: |
  298. SM_CLIENT_CERT_FILE=$RUNNER_TEMP/certificate.p12
  299. echo "$SM_CLIENT_CERT_FILE_B64" | base64 --decode > $SM_CLIENT_CERT_FILE
  300. echo "SM_CLIENT_CERT_FILE=$SM_CLIENT_CERT_FILE" >> "$GITHUB_ENV"
  301. shell: bash
  302. - name: Build and sign packages
  303. if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags'))
  304. shell: powershell
  305. run: |
  306. Get-FileHash $env:SM_CLIENT_CERT_FILE -Algorithm MD5
  307. smksp_registrar.exe list
  308. smctl.exe healthcheck
  309. smctl.exe keypair ls
  310. smctl windows certsync --keypair-alias $env:SM_KEYPAIR_ALIAS
  311. smctl.exe certificate ls
  312. C:\Windows\System32\certutil.exe -csp "DigiCert Signing Manager KSP" -key -user
  313. smksp_cert_sync.exe
  314. # not used but necessary for electron-builder to run
  315. $env:WIN_CSC_LINK=$env:SM_CLIENT_CERT_FILE
  316. $env:WIN_CSC_KEY_PASSWORD=$env:SM_CLIENT_CERT_PASSWORD
  317. node scripts/build-windows.mjs
  318. env:
  319. ARCH: ${{matrix.arch}}
  320. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  321. KEYGEN_TOKEN: ${{ secrets.KEYGEN_TOKEN }}
  322. SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
  323. SM_PUBLISHER_NAME: ${{ secrets.SM_PUBLISHER_NAME }}
  324. SM_API_KEY: ${{ secrets.SM_API_KEY }}
  325. SM_HOST: ${{ vars.SM_HOST }}
  326. SM_CODE_SIGNING_CERT_SHA1_HASH: ${{ vars.SM_CODE_SIGNING_CERT_SHA1_HASH }}
  327. SM_KEYPAIR_ALIAS: ${{ vars.SM_KEYPAIR_ALIAS }}
  328. # DEBUG: electron-builder,electron-builder:*
  329. - name: Build packages without signing
  330. run: node scripts/build-windows.mjs
  331. if: "! (github.event_name == 'push' && (startsWith(github.ref, 'refs/tags')))"
  332. env:
  333. ARCH: ${{matrix.arch}}
  334. - name: Upload symbols
  335. run: |
  336. npm install @sentry/cli
  337. node scripts/sentry-upload.mjs
  338. env:
  339. SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
  340. SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
  341. SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
  342. - name: Package artifacts
  343. run: |
  344. mkdir artifact-setup
  345. mv dist/*-setup-*.exe artifact-setup/
  346. mkdir artifact-portable
  347. mv dist/*-portable-*.zip artifact-portable/
  348. - uses: actions/upload-artifact@master
  349. name: Upload installer
  350. with:
  351. name: Windows installer (${{matrix.arch}})
  352. path: artifact-setup
  353. - uses: actions/upload-artifact@master
  354. name: Upload portable build
  355. with:
  356. name: Windows portable build (${{matrix.arch}})
  357. path: artifact-portable