|
| 1 | +name: 'app-build-release-artifacts' |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - staging |
| 7 | + paths: |
| 8 | + - 'apps/app/**' |
| 9 | + - '.github/workflows/tauri-build-debug.yml' |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - dev |
| 13 | + - staging |
| 14 | + paths: |
| 15 | + - 'apps/app/**' |
| 16 | + - '.github/workflows/tauri-build-debug.yml' |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +jobs: |
| 20 | + publish-tauri: |
| 21 | + environment: production |
| 22 | + permissions: |
| 23 | + contents: write |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + - platform: 'macos-latest' # for Arm based macs (M1 and above). |
| 29 | + args: '--target aarch64-apple-darwin' |
| 30 | + - platform: 'macos-latest' # for Intel based macs. |
| 31 | + args: '--target x86_64-apple-darwin' |
| 32 | + - platform: 'ubuntu-22.04' |
| 33 | + args: '' |
| 34 | + - platform: 'ubuntu-22.04-arm' |
| 35 | + args: '' |
| 36 | + - platform: 'windows-2022' |
| 37 | + args: '' |
| 38 | + - platform: 'windows-11-arm' |
| 39 | + args: '' |
| 40 | + - platform: 'ubuntu-22.04' |
| 41 | + args: '--apk --split-per-abi --target aarch64 --target armv7' |
| 42 | + mobile: 'android' |
| 43 | + runs-on: ${{ matrix.platform }} |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v6 |
| 46 | + |
| 47 | + # ------------- Node & Frontend Cache ------------- |
| 48 | + - name: setup node |
| 49 | + uses: actions/setup-node@v4 |
| 50 | + with: |
| 51 | + node-version: lts/* |
| 52 | + |
| 53 | + - name: setup bun |
| 54 | + uses: oven-sh/setup-bun@v2 |
| 55 | + |
| 56 | + # NEW: Cache Bun dependencies |
| 57 | + - name: Cache Bun dependencies |
| 58 | + uses: actions/cache@v4 |
| 59 | + with: |
| 60 | + path: ~/.bun/install/cache |
| 61 | + key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} |
| 62 | + restore-keys: | |
| 63 | + ${{ runner.os }}-bun- |
| 64 | +
|
| 65 | + # Case 1: Run bun for everything EXCEPT Windows ARM |
| 66 | + - name: install frontend dependencies |
| 67 | + if: matrix.platform != 'windows-11-arm' |
| 68 | + run: bun i |
| 69 | + |
| 70 | + # Case 2: Run npm ONLY for Windows ARM |
| 71 | + - name: install frontend dependencies (Windows ARM) |
| 72 | + if: matrix.platform == 'windows-11-arm' |
| 73 | + run: npm install |
| 74 | + |
| 75 | + # ------------- Rust & Cargo Cache ------------- |
| 76 | + - name: install Rust stable (desktop) |
| 77 | + if: matrix.mobile == '' |
| 78 | + uses: dtolnay/rust-toolchain@stable |
| 79 | + with: |
| 80 | + targets: aarch64-apple-darwin,x86_64-apple-darwin |
| 81 | + |
| 82 | + - name: install Rust stable (android) |
| 83 | + if: matrix.mobile == 'android' |
| 84 | + uses: dtolnay/rust-toolchain@stable |
| 85 | + with: |
| 86 | + targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android |
| 87 | + |
| 88 | + # MODIFIED: Fixed workspaces syntax and ensured shared key matches matrix |
| 89 | + - uses: Swatinem/rust-cache@v2 |
| 90 | + with: |
| 91 | + cache-on-failure: true |
| 92 | + # Point this to the folder containing Cargo.toml. |
| 93 | + # The action automatically handles the 'target' directory. |
| 94 | + workspaces: apps/app/src-tauri |
| 95 | + # Adding a key based on the job matrix helps prevent cache conflicts between platforms |
| 96 | + key: ${{ matrix.platform }}-${{ matrix.args }} |
| 97 | + |
| 98 | + # ------------- Android ------------- |
| 99 | + - name: Set up JDK |
| 100 | + if: matrix.mobile == 'android' |
| 101 | + uses: actions/setup-java@v5 |
| 102 | + with: |
| 103 | + java-version: '17' |
| 104 | + distribution: 'temurin' |
| 105 | + |
| 106 | + # NEW: Cache Gradle for Android |
| 107 | + - name: Cache Gradle |
| 108 | + if: matrix.mobile == 'android' |
| 109 | + uses: actions/cache@v4 |
| 110 | + with: |
| 111 | + path: | |
| 112 | + ~/.gradle/caches |
| 113 | + ~/.gradle/wrapper |
| 114 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 115 | + restore-keys: | |
| 116 | + ${{ runner.os }}-gradle- |
| 117 | +
|
| 118 | + - name: Setup Android SDK |
| 119 | + if: matrix.mobile == 'android' |
| 120 | + uses: android-actions/setup-android@v3 |
| 121 | + - name: Setup Android NDK |
| 122 | + if: matrix.mobile == 'android' |
| 123 | + uses: nttld/setup-ndk@v1 |
| 124 | + id: setup-ndk |
| 125 | + with: |
| 126 | + ndk-version: r29 |
| 127 | + link-to-sdk: true |
| 128 | + - name: setup Android signing |
| 129 | + if: matrix.mobile == 'android' |
| 130 | + run: | |
| 131 | + cd apps/app/src-tauri/gen/android |
| 132 | + echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" > keystore.properties |
| 133 | + echo "password=${{ secrets.ANDROID_KEY_PASSWORD }}" >> keystore.properties |
| 134 | + base64 -d <<< "${{ secrets.ANDROID_KEY_BASE64 }}" > $RUNNER_TEMP/keystore.jks |
| 135 | + echo "storeFile=$RUNNER_TEMP/keystore.jks" >> keystore.properties |
| 136 | +
|
| 137 | + # ------------ Desktop OS ---------------- |
| 138 | + - name: install dependencies (ubuntu only) |
| 139 | + if: startsWith(matrix.platform, 'ubuntu') |
| 140 | + run: | |
| 141 | + sudo apt-get update |
| 142 | + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev xdg-utils |
| 143 | +
|
| 144 | + # ---------------- Tauri ----------------- |
| 145 | + - name: Build Tauri Project |
| 146 | + uses: tauri-apps/tauri-action@8236c82510173ef930d644f38790c4cf3fd43cf2 |
| 147 | + env: |
| 148 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 149 | + NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} |
| 150 | + with: |
| 151 | + projectPath: 'apps/app' |
| 152 | + uploadWorkflowArtifacts: true |
| 153 | + workflowArtifactNamePattern: '[name]-v[version]-[platform]-[arch]-[mode][ext]' |
| 154 | + args: ${{ matrix.args }} |
| 155 | + mobile: ${{ matrix.mobile }} |
0 commit comments