publish-cli-js.yml 13 KB

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