|
| 1 | +name: Build app. |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + os: |
| 15 | + - ubuntu-latest |
| 16 | + - windows-latest |
| 17 | + node-version: |
| 18 | + - 22.x |
| 19 | + |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + - name: 🗄️ Setup Rust cache |
| 24 | + uses: actions/cache@v4 |
| 25 | + with: |
| 26 | + key: ${{ matrix.os }}-${{ hashFiles('src-tauri/Cargo.lock') }} |
| 27 | + path: | |
| 28 | + ~/.cargo/registry/index |
| 29 | + ~/.cargo/registry/cache |
| 30 | + ~/.cargo/git |
| 31 | + ./src-tauri/target |
| 32 | +
|
| 33 | + - name: 🦀 Install Rust |
| 34 | + uses: actions-rs/toolchain@v1 |
| 35 | + with: { toolchain: stable } |
| 36 | + |
| 37 | + - name: 🌐 Update MSEdge webdriver (windowsonly) |
| 38 | + if: matrix.os == 'windows-latest' |
| 39 | + run: | |
| 40 | + choco upgrade microsoft-edge |
| 41 | +
|
| 42 | + - name: 🌐 Install webkit2gtk (ubuntu only) |
| 43 | + if: matrix.os == 'ubuntu-latest' |
| 44 | + run: | |
| 45 | + sudo apt-get update |
| 46 | + sudo apt-get upgrade -y \ |
| 47 | + libwebkit2gtk-4.1-dev \ |
| 48 | + build-essential \ |
| 49 | + curl \ |
| 50 | + wget \ |
| 51 | + file \ |
| 52 | + libxdo-dev \ |
| 53 | + libssl-dev \ |
| 54 | + libayatana-appindicator3-dev \ |
| 55 | + librsvg2-dev |
| 56 | +
|
| 57 | + - uses: pnpm/action-setup@v4 |
| 58 | + with: |
| 59 | + version: 10 |
| 60 | + cache: true |
| 61 | + |
| 62 | + - name: 🟢 Use Node.js ${{ matrix.node-version }} |
| 63 | + uses: actions/setup-node@v4 |
| 64 | + with: |
| 65 | + node-version: ${{ matrix.node-version }} |
| 66 | + cache: 'pnpm' |
| 67 | + |
| 68 | + - name: 🔌 Install Node.js dependencies |
| 69 | + run: pnpm install --frozen-lockfile |
| 70 | + |
| 71 | + - name: 🔌 Download Rust dependencies |
| 72 | + working-directory: src-tauri |
| 73 | + run: cargo fetch |
| 74 | + |
| 75 | + - name: 🏗️ 💽 Build application |
| 76 | + run: pnpm run tauri build |
| 77 | + |
| 78 | + - name: 🧪 Test backend application |
| 79 | + continue-on-error: true |
| 80 | + working-directory: src-tauri |
| 81 | + run: | |
| 82 | + cargo test |
| 83 | +
|
| 84 | + - name: 🗃 Store Linux artifacts (release only) |
| 85 | + uses: actions/upload-artifact@v4 |
| 86 | + if: matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/v') |
| 87 | + with: |
| 88 | + name: pos_sum_artifacts_${{ matrix.os }} |
| 89 | + overwrite: true |
| 90 | + path: | |
| 91 | + src-tauri/target/release/pos_sum |
| 92 | + src-tauri/target/release/bundle/deb/*.deb |
| 93 | +
|
| 94 | + - name: 🗃 Store Windows artifacts (release only) |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + if: matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/v') |
| 97 | + with: |
| 98 | + name: pos_sum_artifacts_${{ matrix.os }} |
| 99 | + overwrite: true |
| 100 | + path: | |
| 101 | + src-tauri/target/release/pos_sum.exe |
| 102 | + src-tauri/target/release/bundle/msi/*.msi |
| 103 | +
|
| 104 | + release: |
| 105 | + runs-on: ubuntu-latest |
| 106 | + needs: |
| 107 | + - build |
| 108 | + if: startsWith(github.ref, 'refs/tags/v') |
| 109 | + steps: |
| 110 | + - uses: actions/checkout@v4 |
| 111 | + |
| 112 | + - name: Create release |
| 113 | + uses: softprops/action-gh-release@v2 |
| 114 | + with: |
| 115 | + tag_name: ${{ github.ref_name }} |
| 116 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 117 | + |
| 118 | + - name: 🗃 Download built artifacts |
| 119 | + uses: actions/download-artifact@v4 |
| 120 | + with: |
| 121 | + path: src-tauri/target/release |
| 122 | + merge-multiple: true |
| 123 | + |
| 124 | + - name: Upload Windows executable |
| 125 | + uses: svenstaro/upload-release-action@v2 |
| 126 | + with: |
| 127 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 128 | + file: src-tauri/target/release/pos_sum.exe |
| 129 | + asset_name: pos_sum_${{ github.ref_name }}.exe |
| 130 | + tag: ${{ github.ref_name }} |
| 131 | + overwrite: true |
| 132 | + file_glob: true |
| 133 | + |
| 134 | + - name: Upload Windows installer |
| 135 | + uses: svenstaro/upload-release-action@v2 |
| 136 | + with: |
| 137 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 138 | + file: src-tauri/target/release/bundle/msi/pos_sum_*.msi |
| 139 | + asset_name: pos_sum_${{ github.ref_name }}_installer.msi |
| 140 | + tag: ${{ github.ref_name }} |
| 141 | + overwrite: true |
| 142 | + file_glob: true |
| 143 | + |
| 144 | + - name: Upload Linux executable |
| 145 | + uses: svenstaro/upload-release-action@v2 |
| 146 | + with: |
| 147 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 148 | + file: src-tauri/target/release/pos_sum |
| 149 | + asset_name: pos_sum_${{ github.ref_name }} |
| 150 | + tag: ${{ github.ref_name }} |
| 151 | + overwrite: true |
| 152 | + file_glob: true |
| 153 | + |
| 154 | + - name: Upload Linux deb package |
| 155 | + uses: svenstaro/upload-release-action@v2 |
| 156 | + with: |
| 157 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 158 | + file: src-tauri/target/release/bundle/deb/pos_sum_*.deb |
| 159 | + asset_name: pos_sum_${{ github.ref_name }}.deb |
| 160 | + tag: ${{ github.ref_name }} |
| 161 | + overwrite: true |
| 162 | + file_glob: true |
0 commit comments