build.yml 13 KB

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