ci.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. name: CI
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. branches: [main]
  7. workflow_dispatch:
  8. jobs:
  9. changes:
  10. name: Detect changes
  11. runs-on: ubuntu-22.04
  12. outputs:
  13. rust: ${{ github.event_name == 'workflow_dispatch' && 'true' || steps.filter.outputs.rust }}
  14. steps:
  15. - name: Checkout
  16. if: github.event_name != 'workflow_dispatch'
  17. uses: actions/checkout@v5
  18. with:
  19. fetch-depth: 0
  20. - name: Filter paths
  21. if: github.event_name != 'workflow_dispatch'
  22. uses: dorny/paths-filter@v4
  23. id: filter
  24. with:
  25. filters: |
  26. rust:
  27. - 'src-tauri/**'
  28. # PR / manual only. Merge to main already passed this on the PR;
  29. # do not compile the same debug tree again.
  30. check:
  31. name: Check Ubuntu
  32. needs: changes
  33. if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
  34. runs-on: ubuntu-22.04
  35. steps:
  36. - name: Checkout
  37. uses: actions/checkout@v5
  38. - name: Install Rust stable
  39. uses: dtolnay/rust-toolchain@stable
  40. - name: Install dependencies
  41. run: |
  42. sudo apt-get update
  43. sudo apt-get install -y curl libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf protobuf-compiler
  44. - name: Rust cache
  45. uses: Swatinem/rust-cache@v2
  46. with:
  47. workspaces: src-tauri
  48. cache-on-failure: true
  49. - name: Setup Node.js
  50. uses: actions/setup-node@v5
  51. with:
  52. node-version: 24
  53. cache: npm
  54. - name: Install frontend dependencies
  55. run: npm ci
  56. - name: Check frontend build
  57. run: npx vite build
  58. - name: Check Rust build
  59. working-directory: src-tauri
  60. run: cargo build
  61. check-windows:
  62. name: Check Windows (Rust)
  63. needs: changes
  64. if: >-
  65. (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch') &&
  66. needs.changes.outputs.rust == 'true'
  67. runs-on: windows-latest
  68. steps:
  69. - name: Checkout
  70. uses: actions/checkout@v5
  71. - name: Install Rust stable
  72. uses: dtolnay/rust-toolchain@stable
  73. - name: Install protoc
  74. uses: arduino/setup-protoc@v3
  75. with:
  76. repo-token: ${{ secrets.GITHUB_TOKEN }}
  77. - name: Rust cache
  78. uses: Swatinem/rust-cache@v2
  79. with:
  80. workspaces: src-tauri
  81. cache-on-failure: true
  82. - name: Check Rust build
  83. working-directory: src-tauri
  84. run: cargo build
  85. # Warm target/release on the default branch so tag builds can restore it.
  86. # Only when src-tauri changes (or manual dispatch). Frontend merges must not
  87. # pay for a 3-platform release compile.
  88. release-compile:
  89. name: Release compile ${{ matrix.display }}
  90. needs: changes
  91. if: github.event_name != 'pull_request' && needs.changes.outputs.rust == 'true'
  92. runs-on: ${{ matrix.platform }}
  93. env:
  94. MACOSX_DEPLOYMENT_TARGET: "13.0"
  95. strategy:
  96. fail-fast: false
  97. matrix:
  98. include:
  99. - platform: ubuntu-22.04
  100. display: Linux x64
  101. # x86_64 / amd64 only. Do not add i686 or aarch64 Linux targets.
  102. - platform: macos-latest
  103. display: macOS
  104. steps:
  105. - name: Checkout
  106. uses: actions/checkout@v5
  107. - name: Install Rust stable
  108. uses: dtolnay/rust-toolchain@stable
  109. - name: Install protoc (macOS)
  110. if: matrix.platform == 'macos-latest'
  111. run: |
  112. brew untap aws/tap || true
  113. brew install protobuf
  114. - name: Install dependencies (Ubuntu)
  115. if: matrix.platform == 'ubuntu-22.04'
  116. run: |
  117. sudo apt-get update
  118. sudo apt-get install -y curl libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf protobuf-compiler
  119. - name: Rust cache
  120. uses: Swatinem/rust-cache@v2
  121. with:
  122. workspaces: src-tauri
  123. shared-key: qmai-release
  124. add-job-id-key: false
  125. cache-on-failure: true
  126. - name: Setup Node.js
  127. uses: actions/setup-node@v5
  128. with:
  129. node-version: 24
  130. cache: npm
  131. - name: Install frontend dependencies
  132. run: npm ci
  133. - name: Build frontend
  134. run: npx vite build
  135. - name: Cargo release build
  136. working-directory: src-tauri
  137. run: cargo build --release
  138. release-compile-windows:
  139. name: Release compile Windows x64
  140. needs: changes
  141. if: github.event_name != 'pull_request' && needs.changes.outputs.rust == 'true'
  142. runs-on: windows-latest
  143. steps:
  144. - name: Checkout
  145. uses: actions/checkout@v5
  146. - name: Install Rust stable
  147. uses: dtolnay/rust-toolchain@stable
  148. - name: Install protoc (Windows)
  149. uses: arduino/setup-protoc@v3
  150. with:
  151. repo-token: ${{ secrets.GITHUB_TOKEN }}
  152. - name: Rust cache
  153. uses: Swatinem/rust-cache@v2
  154. with:
  155. workspaces: src-tauri
  156. shared-key: qmai-release
  157. add-job-id-key: false
  158. cache-on-failure: true
  159. - name: Setup Node.js
  160. uses: actions/setup-node@v5
  161. with:
  162. node-version: 24
  163. cache: npm
  164. - name: Install frontend dependencies
  165. run: npm ci
  166. - name: Build frontend
  167. run: npx vite build
  168. - name: Cargo release build
  169. working-directory: src-tauri
  170. run: cargo build --release