publish-cli-js.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. # Copyright 2019-2024 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-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 --features native-tls-vendored --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@v4
  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 Rust
  102. uses: dtolnay/rust-toolchain@stable
  103. if: ${{ !matrix.settings.docker }}
  104. with:
  105. targets: ${{ matrix.settings.target }}
  106. - uses: Swatinem/rust-cache@v1
  107. with:
  108. key: ${{ matrix.settings.target }}
  109. working-directory: 'tooling/cli/'
  110. if: ${{ matrix.settings.docker }}
  111. - name: Setup toolchain
  112. run: ${{ matrix.settings.setup }}
  113. if: ${{ matrix.settings.setup }}
  114. shell: bash
  115. - name: Install dependencies
  116. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  117. - name: Build in docker
  118. uses: addnab/docker-run-action@v3
  119. if: ${{ matrix.settings.docker }}
  120. with:
  121. image: ${{ matrix.settings.docker }}
  122. 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
  123. run: ${{ matrix.settings.build }}
  124. - name: Build
  125. run: ${{ matrix.settings.build }}
  126. if: ${{ !matrix.settings.docker }}
  127. shell: bash
  128. - name: Upload artifact
  129. uses: actions/upload-artifact@v3
  130. with:
  131. name: bindings-${{ matrix.settings.target }}
  132. path: tooling/cli/node/${{ env.APP_NAME }}.*.node
  133. if-no-files-found: error
  134. # build-freebsd:
  135. # runs-on: macos-10.15
  136. # name: Build FreeBSD
  137. # steps:
  138. # - uses: actions/checkout@v4
  139. # - name: Build
  140. # id: build
  141. # uses: vmactions/freebsd-vm@v0.1.6
  142. # env:
  143. # DEBUG: napi:*
  144. # RUSTUP_HOME: /usr/local/rustup
  145. # CARGO_HOME: /usr/local/cargo
  146. # RUSTUP_IO_THREADS: 1
  147. # with:
  148. # envs: DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS
  149. # usesh: true
  150. # mem: 3000
  151. # prepare: |
  152. # pkg install -y curl node14 python2
  153. # curl -qL https://www.npmjs.com/install.sh | sh
  154. # npm install -g yarn
  155. # curl https://sh.rustup.rs -sSf --output rustup.sh
  156. # sh rustup.sh -y --profile minimal --default-toolchain stable
  157. # export PATH="/usr/local/cargo/bin:$PATH"
  158. # echo "~~~~ rustc --version ~~~~"
  159. # rustc --version
  160. # echo "~~~~ node -v ~~~~"
  161. # node -v
  162. # echo "~~~~ yarn --version ~~~~"
  163. # yarn --version
  164. # run: |
  165. # export PATH="/usr/local/cargo/bin:$PATH"
  166. # pwd
  167. # ls -lah
  168. # whoami
  169. # env
  170. # freebsd-version
  171. # cd ./tooling/cli/node/
  172. # yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  173. # yarn build:release
  174. # strip -x *.node
  175. # rm -rf node_modules
  176. # rm -rf ../target
  177. # - name: Upload artifact
  178. # uses: actions/upload-artifact@v3
  179. # with:
  180. # name: bindings-freebsd
  181. # path: tooling/cli/node/${{ env.APP_NAME }}.*.node
  182. # if-no-files-found: error
  183. test-macOS-windows-binding:
  184. name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
  185. needs:
  186. - build
  187. strategy:
  188. fail-fast: false
  189. matrix:
  190. settings:
  191. - host: macos-latest
  192. target: 'x86_64-apple-darwin'
  193. - host: windows-latest
  194. target: x86_64-pc-windows-msvc
  195. node:
  196. - '14'
  197. - '16'
  198. - '18'
  199. runs-on: ${{ matrix.settings.host }}
  200. steps:
  201. - uses: actions/checkout@v4
  202. - name: Setup node
  203. uses: actions/setup-node@v3
  204. with:
  205. node-version: ${{ matrix.node }}
  206. check-latest: true
  207. cache: yarn
  208. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  209. - name: Install dependencies
  210. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  211. - name: Download artifacts
  212. uses: actions/download-artifact@v3
  213. with:
  214. name: bindings-${{ matrix.settings.target }}
  215. path: 'tooling/cli/node/'
  216. - name: List packages
  217. run: ls -R .
  218. shell: bash
  219. - name: Test bindings
  220. run: yarn test
  221. test-linux-x64-gnu-binding:
  222. name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
  223. needs:
  224. - build
  225. strategy:
  226. fail-fast: false
  227. matrix:
  228. node:
  229. - '14'
  230. - '16'
  231. - '18'
  232. runs-on: ubuntu-latest
  233. steps:
  234. - uses: actions/checkout@v4
  235. - name: Setup node
  236. uses: actions/setup-node@v3
  237. with:
  238. node-version: ${{ matrix.node }}
  239. check-latest: true
  240. cache: yarn
  241. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  242. - name: Install dependencies
  243. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  244. - name: Download artifacts
  245. uses: actions/download-artifact@v3
  246. with:
  247. name: bindings-x86_64-unknown-linux-gnu
  248. path: 'tooling/cli/node/'
  249. - name: List packages
  250. run: ls -R .
  251. shell: bash
  252. - name: install system dependencies
  253. run: |
  254. sudo apt-get update
  255. sudo apt-get install -y webkit2gtk-4.1 libayatana-appindicator3-dev
  256. - name: Test bindings
  257. run: yarn test
  258. test-linux-x64-musl-binding:
  259. name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }}
  260. needs:
  261. - build
  262. strategy:
  263. fail-fast: false
  264. matrix:
  265. node:
  266. - '14'
  267. - '16'
  268. - '18'
  269. runs-on: ubuntu-latest
  270. container:
  271. image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
  272. steps:
  273. - uses: actions/checkout@v4
  274. - name: Setup node
  275. uses: actions/setup-node@v3
  276. with:
  277. node-version: ${{ matrix.node }}
  278. check-latest: true
  279. cache: yarn
  280. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  281. - name: Install dependencies
  282. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  283. - name: Download artifacts
  284. uses: actions/download-artifact@v3
  285. with:
  286. name: bindings-x86_64-unknown-linux-musl
  287. path: 'tooling/cli/node/'
  288. - name: List packages
  289. run: ls -R .
  290. shell: bash
  291. - name: Setup and run tests
  292. run: |
  293. yarn tauri --help
  294. ls -la
  295. #- name: Setup and run tests
  296. # run: |
  297. # rustup install stable
  298. # rustup default stable
  299. # yarn test
  300. # ls -la
  301. test-linux-arm-bindings:
  302. name: Test bindings on ${{ matrix.image }} - node@${{ matrix.node }}
  303. needs:
  304. - build
  305. strategy:
  306. fail-fast: false
  307. matrix:
  308. node:
  309. - '14'
  310. - '16'
  311. - '18'
  312. image:
  313. - ghcr.io/napi-rs/napi-rs/nodejs:aarch64-16
  314. - ghcr.io/napi-rs/napi-rs/nodejs:armhf-16
  315. runs-on: ubuntu-latest
  316. steps:
  317. - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
  318. working-directory: ${{ github.workspace }}
  319. - uses: actions/checkout@v4
  320. - name: List packages
  321. run: ls -R .
  322. shell: bash
  323. - name: Install dependencies
  324. run: yarn install --ignore-scripts --ignore-platform --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  325. - name: Download aarch64-gnu artifacts
  326. uses: actions/download-artifact@v3
  327. with:
  328. name: bindings-aarch64-unknown-linux-gnu
  329. path: 'tooling/cli/node/'
  330. - name: Download armv7-gnueabihf artifacts
  331. uses: actions/download-artifact@v3
  332. with:
  333. name: bindings-armv7-unknown-linux-gnueabihf
  334. path: 'tooling/cli/node/'
  335. # TODO: actually run test, blocked by https://github.com/rust-lang/cargo/issues/8719
  336. - uses: addnab/docker-run-action@v3
  337. with:
  338. image: ${{ matrix.image }}
  339. options: '-v ${{ github.workspace }}:/build -w /build -e RUSTUP_HOME=/usr/local/rustup -e CARGO_HOME=/usr/local/cargo'
  340. shell: bash
  341. run: |
  342. set -e
  343. export PATH=/usr/local/cargo/bin/:/usr/local/fnm:$PATH
  344. apt-get update
  345. DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --no-install-recommends -y unzip libayatana-appindicator3-dev
  346. bash
  347. curl https://sh.rustup.rs -sSf | bash -s -- -y
  348. curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/usr/local/fnm" --skip-shell
  349. eval "$(fnm env --use-on-cd)"
  350. fnm install ${{ matrix.node }}
  351. fnm use ${{ matrix.node }}
  352. cd tooling/cli/node
  353. yarn tauri --help
  354. ls -la
  355. publish:
  356. name: Publish
  357. runs-on: ubuntu-latest
  358. needs:
  359. #- build-freebsd
  360. - test-macOS-windows-binding
  361. - test-linux-x64-gnu-binding
  362. - test-linux-x64-musl-binding
  363. #- test-linux-arm-bindings
  364. steps:
  365. - uses: actions/checkout@v4
  366. - name: Setup node
  367. uses: actions/setup-node@v3
  368. with:
  369. node-version: 16
  370. check-latest: true
  371. cache: yarn
  372. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  373. - name: Install dependencies
  374. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  375. - name: Download all artifacts
  376. uses: actions/download-artifact@v3
  377. with:
  378. path: tooling/cli/node/artifacts
  379. - name: Move artifacts
  380. run: yarn artifacts
  381. - name: List packages
  382. run: ls -R ./npm
  383. shell: bash
  384. - name: Publish
  385. run: |
  386. echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
  387. npm publish --tag next
  388. env:
  389. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  390. NPM_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
  391. RELEASE_ID: ${{ github.event.client_payload.releaseId || inputs.releaseId }}