publish-cli-js.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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 --target=x86_64-apple-darwin
  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 node16 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: 'aarch64-apple-darwin'
  196. - host: windows-latest
  197. target: x86_64-pc-windows-msvc
  198. node:
  199. - '16'
  200. - '18'
  201. - '20'
  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. - '16'
  233. - '18'
  234. - '20'
  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. - '16'
  270. - '18'
  271. - '20'
  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: Setup and run tests
  295. run: |
  296. yarn tauri --help
  297. ls -la
  298. #- name: Setup and run tests
  299. # run: |
  300. # rustup install stable
  301. # rustup default stable
  302. # yarn test
  303. # ls -la
  304. test-linux-arm-bindings:
  305. name: Test bindings on ${{ matrix.image }} - node@${{ matrix.node }}
  306. needs:
  307. - build
  308. strategy:
  309. fail-fast: false
  310. matrix:
  311. node:
  312. - '16'
  313. - '18'
  314. - '20'
  315. image:
  316. - ghcr.io/napi-rs/napi-rs/nodejs:aarch64-16
  317. - ghcr.io/napi-rs/napi-rs/nodejs:armhf-16
  318. runs-on: ubuntu-latest
  319. steps:
  320. - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
  321. working-directory: ${{ github.workspace }}
  322. - uses: actions/checkout@v3
  323. - name: List packages
  324. run: ls -R .
  325. shell: bash
  326. - name: Install dependencies
  327. run: yarn install --ignore-scripts --ignore-platform --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  328. - name: Download aarch64-gnu artifacts
  329. uses: actions/download-artifact@v3
  330. with:
  331. name: bindings-aarch64-unknown-linux-gnu
  332. path: 'tooling/cli/node/'
  333. - name: Download armv7-gnueabihf artifacts
  334. uses: actions/download-artifact@v3
  335. with:
  336. name: bindings-armv7-unknown-linux-gnueabihf
  337. path: 'tooling/cli/node/'
  338. # TODO: actually run test, blocked by https://github.com/rust-lang/cargo/issues/8719
  339. - uses: addnab/docker-run-action@v3
  340. with:
  341. image: ${{ matrix.image }}
  342. options: '-v ${{ github.workspace }}:/build -w /build -e RUSTUP_HOME=/usr/local/rustup -e CARGO_HOME=/usr/local/cargo'
  343. shell: bash
  344. run: |
  345. set -e
  346. export PATH=/usr/local/cargo/bin/:/usr/local/fnm:$PATH
  347. apt-get update
  348. DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --no-install-recommends -y unzip webkit2gtk-4.0 libayatana-appindicator3-dev
  349. bash
  350. curl https://sh.rustup.rs -sSf | bash -s -- -y
  351. curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/usr/local/fnm" --skip-shell
  352. eval "$(fnm env --use-on-cd)"
  353. fnm install ${{ matrix.node }}
  354. fnm use ${{ matrix.node }}
  355. cd tooling/cli/node
  356. yarn tauri --help
  357. ls -la
  358. publish:
  359. name: Publish
  360. runs-on: ubuntu-latest
  361. needs:
  362. #- build-freebsd
  363. - test-macOS-windows-binding
  364. - test-linux-x64-gnu-binding
  365. - test-linux-x64-musl-binding
  366. #- test-linux-arm-bindings
  367. steps:
  368. - uses: actions/checkout@v3
  369. - name: Setup node
  370. uses: actions/setup-node@v3
  371. with:
  372. node-version: 20
  373. check-latest: true
  374. cache: yarn
  375. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  376. - name: Install dependencies
  377. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  378. - name: Download all artifacts
  379. uses: actions/download-artifact@v3
  380. with:
  381. path: tooling/cli/node/artifacts
  382. - name: Move artifacts
  383. run: yarn artifacts
  384. - name: List packages
  385. run: ls -R ./npm
  386. shell: bash
  387. - name: Publish
  388. run: |
  389. echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
  390. npm publish
  391. env:
  392. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  393. NPM_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
  394. RELEASE_ID: ${{ github.event.client_payload.releaseId || github.event.inputs.releaseId }}