跨平台编译

Tauri 只能构建当前操作系统的对应的应用,官方提供了 GitHub Actions 脚本来进行跨平台编译。
GitHub Actions不太熟悉的,可以先了解一下。
Github Action 使用

在根目录创建 .github/workflows/release.yml

  1. name: 'Release'
  2. on:
  3. push:
  4. tags:
  5. - 'v*'
  6. workflow_dispatch:
  7. jobs:
  8. release:
  9. strategy:
  10. fail-fast: false
  11. matrix:
  12. platform: [macos-latest, ubuntu-latest, windows-latest]
  13. runs-on: ${{ matrix.platform }}
  14. steps:
  15. - name: Checkout repository
  16. uses: actions/checkout@v2
  17. - name: Node.js setup
  18. uses: actions/setup-node@v1
  19. with:
  20. node-version: 16
  21. - name: Rust setup
  22. uses: actions-rs/toolchain@v1
  23. with:
  24. toolchain: stable
  25. - name: Install dependencies (ubuntu only)
  26. if: matrix.platform == 'ubuntu-latest'
  27. run: |
  28. sudo apt-get update
  29. sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
  30. - name: Install app dependencies and build web
  31. run: yarn && yarn build
  32. - name: Build the app
  33. uses: tauri-apps/tauri-action@v0
  34. env:
  35. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  36. with:
  37. tagName: v__VERSION__ # tauri-action replaces \_\_VERSION\_\_ with the app version
  38. releaseName: 'v__VERSION__'
  39. releaseBody: 'See the assets to download this version and install.'
  40. releaseDraft: true
  41. prerelease: false

直接使用的官方给的例子,流程就是打以 v 开头的 tag,触发构建,构建成功后自动创建 release 草稿,并附上制品。
image.png
image.png

应用签名