publish-cli-js.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. name: publish cli.js
  2. env:
  3. DEBUG: napi:*
  4. APP_NAME: cli
  5. MACOSX_DEPLOYMENT_TARGET: '10.13'
  6. on:
  7. workflow_dispatch:
  8. inputs:
  9. releaseId:
  10. description: 'ID of the cli.js release'
  11. required: true
  12. repository_dispatch:
  13. types: [publish-clijs]
  14. defaults:
  15. run:
  16. working-directory: tooling/cli/node/
  17. jobs:
  18. build:
  19. strategy:
  20. fail-fast: false
  21. matrix:
  22. settings:
  23. - host: macos-latest
  24. target: x86_64-apple-darwin
  25. architecture: x64
  26. build: |
  27. yarn build:release
  28. strip -x *.node
  29. - host: windows-latest
  30. build: yarn build:release
  31. target: x86_64-pc-windows-msvc
  32. architecture: x64
  33. - host: windows-latest
  34. build: yarn build:release --target i686-pc-windows-msvc
  35. target: i686-pc-windows-msvc
  36. architecture: x64
  37. - host: ubuntu-18.04
  38. target: x86_64-unknown-linux-gnu
  39. docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
  40. build: |
  41. cd tooling/cli/node
  42. yarn build:release --target x86_64-unknown-linux-gnu
  43. strip *.node
  44. - host: ubuntu-18.04
  45. target: x86_64-unknown-linux-musl
  46. docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
  47. build: |
  48. cd tooling/cli/node
  49. yarn build:release
  50. strip *.node
  51. - host: macos-latest
  52. target: aarch64-apple-darwin
  53. build: |
  54. yarn build:release --target=aarch64-apple-darwin
  55. strip -x *.node
  56. - host: ubuntu-18.04
  57. target: aarch64-unknown-linux-gnu
  58. docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
  59. build: |
  60. cd tooling/cli/node
  61. yarn build:release --target aarch64-unknown-linux-gnu
  62. aarch64-unknown-linux-gnu-strip *.node
  63. - host: ubuntu-18.04
  64. architecture: x64
  65. target: armv7-unknown-linux-gnueabihf
  66. setup: |
  67. sudo apt-get update
  68. sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
  69. build: |
  70. yarn build:release --target=armv7-unknown-linux-gnueabihf
  71. arm-linux-gnueabihf-strip *.node
  72. - host: ubuntu-18.04
  73. architecture: x64
  74. target: aarch64-unknown-linux-musl
  75. docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
  76. build: |
  77. cd tooling/cli/node
  78. rustup target add aarch64-unknown-linux-musl
  79. yarn build:release --target aarch64-unknown-linux-musl
  80. /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
  81. #- host: windows-latest
  82. # architecture: x64
  83. # target: aarch64-pc-windows-msvc
  84. # build: yarn build:release --target aarch64-pc-windows-msvc
  85. name: stable - ${{ matrix.settings.target }} - node@16
  86. runs-on: ${{ matrix.settings.host }}
  87. steps:
  88. - uses: actions/checkout@v3
  89. - name: Setup node
  90. uses: actions/setup-node@v3
  91. if: ${{ !matrix.settings.docker }}
  92. with:
  93. node-version: 16
  94. check-latest: true
  95. cache: yarn
  96. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  97. architecture: ${{ matrix.settings.architecture }}
  98. - name: Install
  99. uses: actions-rs/toolchain@v1
  100. if: ${{ !matrix.settings.docker }}
  101. with:
  102. profile: minimal
  103. override: true
  104. toolchain: stable
  105. target: ${{ 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@v3
  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@v3
  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@v3
  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.0 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@v3
  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: Install system dependencies
  292. run: |
  293. apk add openssl-dev musl-dev glib-dev cairo-dev pkgconfig gdk-pixbuf-dev webkit2gtk-dev curl libappindicator-dev gtk+3.0-dev
  294. - name: Setup and run tests
  295. run: |
  296. yarn tauri --help
  297. ls -la
  298. # TODO: fix this test: https://github.com/tauri-apps/tauri/runs/5145729140?check_suite_focus=true#step:9:704
  299. #- name: Setup and run tests
  300. # run: |
  301. # rustup install stable
  302. # rustup default stable
  303. # yarn test
  304. # ls -la
  305. test-linux-arm-bindings:
  306. name: Test bindings on ${{ matrix.image }} - node@${{ matrix.node }}
  307. needs:
  308. - build
  309. strategy:
  310. fail-fast: false
  311. matrix:
  312. node:
  313. - '14'
  314. - '16'
  315. - '18'
  316. image:
  317. - ghcr.io/napi-rs/napi-rs/nodejs:aarch64-16
  318. - ghcr.io/napi-rs/napi-rs/nodejs:armhf-16
  319. runs-on: ubuntu-latest
  320. steps:
  321. - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
  322. working-directory: ${{ github.workspace }}
  323. - uses: actions/checkout@v3
  324. - name: List packages
  325. run: ls -R .
  326. shell: bash
  327. - name: Install dependencies
  328. run: yarn install --ignore-scripts --ignore-platform --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  329. - name: Download aarch64-gnu artifacts
  330. uses: actions/download-artifact@v3
  331. with:
  332. name: bindings-aarch64-unknown-linux-gnu
  333. path: 'tooling/cli/node/'
  334. - name: Download armv7-gnueabihf artifacts
  335. uses: actions/download-artifact@v3
  336. with:
  337. name: bindings-armv7-unknown-linux-gnueabihf
  338. path: 'tooling/cli/node/'
  339. # TODO: actually run test, blocked by https://github.com/rust-lang/cargo/issues/8719
  340. - uses: addnab/docker-run-action@v3
  341. with:
  342. image: ${{ matrix.image }}
  343. options: '-v ${{ github.workspace }}:/build -w /build -e RUSTUP_HOME=/usr/local/rustup -e CARGO_HOME=/usr/local/cargo'
  344. shell: bash
  345. run: |
  346. set -e
  347. export PATH=/usr/local/cargo/bin/:/usr/local/fnm:$PATH
  348. apt-get update
  349. DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --no-install-recommends -y unzip webkit2gtk-4.0 libayatana-appindicator3-dev
  350. bash
  351. curl https://sh.rustup.rs -sSf | bash -s -- -y
  352. curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/usr/local/fnm" --skip-shell
  353. eval "$(fnm env --use-on-cd)"
  354. fnm install ${{ matrix.node }}
  355. fnm use ${{ matrix.node }}
  356. cd tooling/cli/node
  357. yarn tauri --help
  358. ls -la
  359. publish:
  360. name: Publish
  361. runs-on: ubuntu-latest
  362. needs:
  363. #- build-freebsd
  364. - test-macOS-windows-binding
  365. - test-linux-x64-gnu-binding
  366. - test-linux-x64-musl-binding
  367. #- test-linux-arm-bindings
  368. steps:
  369. - uses: actions/checkout@v3
  370. - name: Setup node
  371. uses: actions/setup-node@v3
  372. with:
  373. node-version: 16
  374. check-latest: true
  375. cache: yarn
  376. cache-dependency-path: 'tooling/cli/node/yarn.lock'
  377. - name: Install dependencies
  378. run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
  379. - name: Download all artifacts
  380. uses: actions/download-artifact@v3
  381. with:
  382. path: tooling/cli/node/artifacts
  383. - name: Move artifacts
  384. run: yarn artifacts
  385. - name: List packages
  386. run: ls -R ./npm
  387. shell: bash
  388. - name: Publish
  389. run: |
  390. echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
  391. npm publish
  392. env:
  393. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  394. NPM_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
  395. RELEASE_ID: ${{ github.event.client_payload.releaseId || github.event.inputs.releaseId }}