publish-cli-js.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. # Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  2. # SPDX-License-Identifier: Apache-2.0
  3. # SPDX-License-Identifier: MIT
  4. name: publish `@tauri-apps/cli`
  5. env:
  6. DEBUG: napi:*
  7. APP_NAME: cli
  8. MACOSX_DEPLOYMENT_TARGET: '10.13'
  9. on:
  10. workflow_dispatch:
  11. inputs:
  12. releaseId:
  13. description: 'ID of the `@tauri-apps/cli` release'
  14. required: true
  15. repository_dispatch:
  16. types: [publish-js-cli]
  17. defaults:
  18. run:
  19. working-directory: tooling/cli/node/
  20. jobs:
  21. build:
  22. strategy:
  23. fail-fast: false
  24. matrix:
  25. settings:
  26. - host: macos-latest
  27. target: x86_64-apple-darwin
  28. architecture: x64
  29. build: |
  30. yarn build:release
  31. strip -x *.node
  32. - host: windows-latest
  33. build: yarn build:release
  34. target: x86_64-pc-windows-msvc
  35. architecture: x64
  36. - host: windows-latest
  37. build: yarn build:release --target i686-pc-windows-msvc
  38. target: i686-pc-windows-msvc
  39. architecture: x64
  40. - host: windows-latest
  41. architecture: x64
  42. target: aarch64-pc-windows-msvc
  43. build: yarn build:release --target aarch64-pc-windows-msvc --features native-tls,native-tls-vendored --cargo-flags="--no-default-features"
  44. - host: ubuntu-20.04
  45. target: x86_64-unknown-linux-gnu
  46. docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
  47. build: |
  48. cd tooling/cli/node
  49. yarn build:release --target x86_64-unknown-linux-gnu
  50. strip *.node
  51. - host: ubuntu-20.04
  52. target: x86_64-unknown-linux-musl
  53. docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
  54. build: |
  55. cd tooling/cli/node
  56. yarn build:release
  57. strip *.node
  58. - host: macos-latest
  59. target: aarch64-apple-darwin
  60. build: |
  61. yarn build:release --target=aarch64-apple-darwin
  62. strip -x *.node
  63. - host: ubuntu-20.04
  64. target: aarch64-unknown-linux-gnu
  65. docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
  66. build: |
  67. cd tooling/cli/node
  68. yarn build:release --target aarch64-unknown-linux-gnu
  69. aarch64-unknown-linux-gnu-strip *.node
  70. - host: ubuntu-20.04
  71. architecture: x64
  72. target: armv7-unknown-linux-gnueabihf
  73. setup: |
  74. sudo apt-get update
  75. sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
  76. build: |
  77. yarn build:release --target=armv7-unknown-linux-gnueabihf
  78. arm-linux-gnueabihf-strip *.node
  79. - host: ubuntu-20.04
  80. architecture: x64
  81. target: aarch64-unknown-linux-musl
  82. docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
  83. build: |
  84. cd tooling/cli/node
  85. rustup target add aarch64-unknown-linux-musl
  86. yarn build:release --target aarch64-unknown-linux-musl
  87. /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
  88. name: stable - ${{ matrix.settings.target }} - node@16
  89. runs-on: ${{ matrix.settings.host }}
  90. steps:
  91. - uses: actions/checkout@v3
  92. - name: Setup node
  93. uses: actions/setup-node@v3
  94. if: ${{ !matrix.settings.docker }}
  95. with:
  96. node-version: 16
  97. check-latest: true
  98. cache: yarn
  99. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  100. architecture: ${{ matrix.settings.architecture }}
  101. - name: Install
  102. uses: actions-rs/toolchain@v1
  103. if: ${{ !matrix.settings.docker }}
  104. with:
  105. profile: minimal
  106. override: true
  107. toolchain: stable
  108. target: ${{ matrix.settings.target }}
  109. - uses: Swatinem/rust-cache@v1
  110. with:
  111. key: ${{ matrix.settings.target }}
  112. working-directory: 'tooling/cli/'
  113. if: ${{ matrix.settings.docker }}
  114. - name: Setup toolchain
  115. run: ${{ matrix.settings.setup }}
  116. if: ${{ matrix.settings.setup }}
  117. shell: bash
  118. - name: Install dependencies
  119. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  120. - name: Build in docker
  121. uses: addnab/docker-run-action@v3
  122. if: ${{ matrix.settings.docker }}
  123. with:
  124. image: ${{ matrix.settings.docker }}
  125. options: --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/root/.cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/root/.cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/root/.cargo/registry/index -v ${{ github.workspace }}:/build -w /build
  126. run: ${{ matrix.settings.build }}
  127. - name: Build
  128. run: ${{ matrix.settings.build }}
  129. if: ${{ !matrix.settings.docker }}
  130. shell: bash
  131. - name: Upload artifact
  132. uses: actions/upload-artifact@v3
  133. with:
  134. name: bindings-${{ matrix.settings.target }}
  135. path: tooling/cli/node/${{ env.APP_NAME }}.*.node
  136. if-no-files-found: error
  137. # build-freebsd:
  138. # runs-on: macos-10.15
  139. # name: Build FreeBSD
  140. # steps:
  141. # - uses: actions/checkout@v3
  142. # - name: Build
  143. # id: build
  144. # uses: vmactions/freebsd-vm@v0.1.6
  145. # env:
  146. # DEBUG: napi:*
  147. # RUSTUP_HOME: /usr/local/rustup
  148. # CARGO_HOME: /usr/local/cargo
  149. # RUSTUP_IO_THREADS: 1
  150. # with:
  151. # envs: DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS
  152. # usesh: true
  153. # mem: 3000
  154. # prepare: |
  155. # pkg install -y curl node14 python2
  156. # curl -qL https://www.npmjs.com/install.sh | sh
  157. # npm install -g yarn
  158. # curl https://sh.rustup.rs -sSf --output rustup.sh
  159. # sh rustup.sh -y --profile minimal --default-toolchain stable
  160. # export PATH="/usr/local/cargo/bin:$PATH"
  161. # echo "~~~~ rustc --version ~~~~"
  162. # rustc --version
  163. # echo "~~~~ node -v ~~~~"
  164. # node -v
  165. # echo "~~~~ yarn --version ~~~~"
  166. # yarn --version
  167. # run: |
  168. # export PATH="/usr/local/cargo/bin:$PATH"
  169. # pwd
  170. # ls -lah
  171. # whoami
  172. # env
  173. # freebsd-version
  174. # cd ./tooling/cli/node/
  175. # yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  176. # yarn build:release
  177. # strip -x *.node
  178. # rm -rf node_modules
  179. # rm -rf ../target
  180. # - name: Upload artifact
  181. # uses: actions/upload-artifact@v3
  182. # with:
  183. # name: bindings-freebsd
  184. # path: tooling/cli/node/${{ env.APP_NAME }}.*.node
  185. # if-no-files-found: error
  186. test-macOS-windows-binding:
  187. name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
  188. needs:
  189. - build
  190. strategy:
  191. fail-fast: false
  192. matrix:
  193. settings:
  194. - host: macos-latest
  195. target: 'x86_64-apple-darwin'
  196. - host: windows-latest
  197. target: x86_64-pc-windows-msvc
  198. node:
  199. - '14'
  200. - '16'
  201. - '18'
  202. runs-on: ${{ matrix.settings.host }}
  203. steps:
  204. - uses: actions/checkout@v3
  205. - name: Setup node
  206. uses: actions/setup-node@v3
  207. with:
  208. node-version: ${{ matrix.node }}
  209. check-latest: true
  210. cache: yarn
  211. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  212. - name: Install dependencies
  213. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  214. - name: Download artifacts
  215. uses: actions/download-artifact@v3
  216. with:
  217. name: bindings-${{ matrix.settings.target }}
  218. path: 'tooling/cli/node/'
  219. - name: List packages
  220. run: ls -R .
  221. shell: bash
  222. - name: Test bindings
  223. run: yarn test
  224. test-linux-x64-gnu-binding:
  225. name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
  226. needs:
  227. - build
  228. strategy:
  229. fail-fast: false
  230. matrix:
  231. node:
  232. - '14'
  233. - '16'
  234. - '18'
  235. runs-on: ubuntu-latest
  236. steps:
  237. - uses: actions/checkout@v3
  238. - name: Setup node
  239. uses: actions/setup-node@v3
  240. with:
  241. node-version: ${{ matrix.node }}
  242. check-latest: true
  243. cache: yarn
  244. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  245. - name: Install dependencies
  246. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  247. - name: Download artifacts
  248. uses: actions/download-artifact@v3
  249. with:
  250. name: bindings-x86_64-unknown-linux-gnu
  251. path: 'tooling/cli/node/'
  252. - name: List packages
  253. run: ls -R .
  254. shell: bash
  255. - name: install system dependencies
  256. run: |
  257. sudo apt-get update
  258. sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
  259. - name: Test bindings
  260. run: yarn test
  261. test-linux-x64-musl-binding:
  262. name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }}
  263. needs:
  264. - build
  265. strategy:
  266. fail-fast: false
  267. matrix:
  268. node:
  269. - '14'
  270. - '16'
  271. - '18'
  272. runs-on: ubuntu-latest
  273. container:
  274. image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
  275. steps:
  276. - uses: actions/checkout@v3
  277. - name: Setup node
  278. uses: actions/setup-node@v3
  279. with:
  280. node-version: ${{ matrix.node }}
  281. check-latest: true
  282. cache: yarn
  283. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  284. - name: Install dependencies
  285. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  286. - name: Download artifacts
  287. uses: actions/download-artifact@v3
  288. with:
  289. name: bindings-x86_64-unknown-linux-musl
  290. path: 'tooling/cli/node/'
  291. - name: List packages
  292. run: ls -R .
  293. shell: bash
  294. - name: Install system dependencies
  295. run: |
  296. apk add openssl-dev musl-dev glib-dev cairo-dev pkgconfig gdk-pixbuf-dev webkit2gtk-dev curl gtk+3.0-dev
  297. - name: Setup and run tests
  298. run: |
  299. yarn tauri --help
  300. ls -la
  301. # TODO: fix this test: https://github.com/tauri-apps/tauri/runs/5145729140?check_suite_focus=true#step:9:704
  302. #- name: Setup and run tests
  303. # run: |
  304. # rustup install stable
  305. # rustup default stable
  306. # yarn test
  307. # ls -la
  308. test-linux-arm-bindings:
  309. name: Test bindings on ${{ matrix.image }} - node@${{ matrix.node }}
  310. needs:
  311. - build
  312. strategy:
  313. fail-fast: false
  314. matrix:
  315. node:
  316. - '14'
  317. - '16'
  318. - '18'
  319. image:
  320. - ghcr.io/napi-rs/napi-rs/nodejs:aarch64-16
  321. - ghcr.io/napi-rs/napi-rs/nodejs:armhf-16
  322. runs-on: ubuntu-latest
  323. steps:
  324. - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
  325. working-directory: ${{ github.workspace }}
  326. - uses: actions/checkout@v3
  327. - name: List packages
  328. run: ls -R .
  329. shell: bash
  330. - name: Install dependencies
  331. run: yarn install --ignore-scripts --ignore-platform --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  332. - name: Download aarch64-gnu artifacts
  333. uses: actions/download-artifact@v3
  334. with:
  335. name: bindings-aarch64-unknown-linux-gnu
  336. path: 'tooling/cli/node/'
  337. - name: Download armv7-gnueabihf artifacts
  338. uses: actions/download-artifact@v3
  339. with:
  340. name: bindings-armv7-unknown-linux-gnueabihf
  341. path: 'tooling/cli/node/'
  342. # TODO: actually run test, blocked by https://github.com/rust-lang/cargo/issues/8719
  343. - uses: addnab/docker-run-action@v3
  344. with:
  345. image: ${{ matrix.image }}
  346. options: '-v ${{ github.workspace }}:/build -w /build -e RUSTUP_HOME=/usr/local/rustup -e CARGO_HOME=/usr/local/cargo'
  347. shell: bash
  348. run: |
  349. set -e
  350. export PATH=/usr/local/cargo/bin/:/usr/local/fnm:$PATH
  351. apt-get update
  352. DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --no-install-recommends -y unzip webkit2gtk-4.0 libayatana-appindicator3-dev
  353. bash
  354. curl https://sh.rustup.rs -sSf | bash -s -- -y
  355. curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/usr/local/fnm" --skip-shell
  356. eval "$(fnm env --use-on-cd)"
  357. fnm install ${{ matrix.node }}
  358. fnm use ${{ matrix.node }}
  359. cd tooling/cli/node
  360. yarn tauri --help
  361. ls -la
  362. publish:
  363. name: Publish
  364. runs-on: ubuntu-latest
  365. needs:
  366. #- build-freebsd
  367. - test-macOS-windows-binding
  368. - test-linux-x64-gnu-binding
  369. - test-linux-x64-musl-binding
  370. #- test-linux-arm-bindings
  371. steps:
  372. - uses: actions/checkout@v3
  373. - name: Setup node
  374. uses: actions/setup-node@v3
  375. with:
  376. node-version: 16
  377. check-latest: true
  378. cache: yarn
  379. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  380. - name: Install dependencies
  381. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  382. - name: Download all artifacts
  383. uses: actions/download-artifact@v3
  384. with:
  385. path: tooling/cli/node/artifacts
  386. - name: Move artifacts
  387. run: yarn artifacts
  388. - name: List packages
  389. run: ls -R ./npm
  390. shell: bash
  391. - name: Publish
  392. run: |
  393. echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
  394. npm publish
  395. env:
  396. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  397. NPM_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
  398. RELEASE_ID: ${{ github.event.client_payload.releaseId || github.event.inputs.releaseId }}