publish-cli-js.yml 14 KB

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