|  | 
| 1 |  | -# Builds Betaflight Configurator on Windows, Android, Linux and macOS platforms. | 
| 2 |  | -# | 
| 3 |  | -# After building, artifacts are released to a separate repository. | 
| 4 |  | - | 
| 5 | 1 | name: CI | 
| 6 | 2 | 
 | 
|  | 3 | +# Run on PRs to show artifacts, and keep callable for reuse. | 
| 7 | 4 | on: | 
|  | 5 | +  pull_request: | 
|  | 6 | +  push: | 
|  | 7 | +    branches: [ tauri ] | 
| 8 | 8 |   workflow_call: | 
| 9 | 9 |     inputs: | 
| 10 |  | -      debug_build: | 
| 11 |  | -        description: 'Specifies if it is a debug build or a release build' | 
| 12 |  | -        default: true | 
|  | 10 | +      run_docker_build: | 
|  | 11 | +        description: 'Also try a Docker build if a Dockerfile exists' | 
| 13 | 12 |         required: false | 
|  | 13 | +        default: false | 
| 14 | 14 |         type: boolean | 
| 15 | 15 | 
 | 
| 16 | 16 | jobs: | 
| 17 |  | -  test: | 
| 18 |  | -    name: Test | 
|  | 17 | +  node-ci: | 
|  | 18 | +    name: Lint, test, and build (Node) | 
| 19 | 19 |     runs-on: ubuntu-latest | 
| 20 | 20 |     steps: | 
| 21 |  | -      - uses: actions/checkout@v5 | 
|  | 21 | +      - name: Checkout | 
|  | 22 | +        uses: actions/checkout@v5 | 
|  | 23 | + | 
|  | 24 | +      - name: Setup Node | 
|  | 25 | +        uses: actions/setup-node@v5 | 
|  | 26 | +        with: | 
|  | 27 | +          node-version-file: '.nvmrc' | 
|  | 28 | +          cache: 'yarn' | 
|  | 29 | + | 
|  | 30 | +      - name: Install dependencies (Yarn classic) | 
|  | 31 | +        run: yarn install --frozen-lockfile | 
|  | 32 | + | 
|  | 33 | +      - name: Lint | 
|  | 34 | +        run: yarn lint | 
|  | 35 | + | 
|  | 36 | +      - name: Unit tests | 
|  | 37 | +        run: yarn test --run | 
|  | 38 | + | 
|  | 39 | +      - name: Build web (Vite) | 
|  | 40 | +        run: yarn build | 
| 22 | 41 | 
 | 
| 23 |  | -      - name: Cache node_modules | 
| 24 |  | -        uses: actions/cache@v4 | 
|  | 42 | +      - name: Upload web dist | 
|  | 43 | +        uses: actions/upload-artifact@v4 | 
| 25 | 44 |         with: | 
| 26 |  | -          path: node_modules/ | 
| 27 |  | -          key: node_modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }} | 
|  | 45 | +          name: web-dist | 
|  | 46 | +          path: src/dist/ | 
|  | 47 | +          if-no-files-found: warn | 
|  | 48 | +          retention-days: 14 | 
| 28 | 49 | 
 | 
| 29 |  | -      - name: Install Node.js | 
|  | 50 | +  tauri-linux-preview: | 
|  | 51 | +    name: Tauri Linux preview (deb/appimage) | 
|  | 52 | +    runs-on: ubuntu-latest | 
|  | 53 | +    needs: node-ci | 
|  | 54 | +    if: ${{ github.event_name == 'pull_request' }} | 
|  | 55 | +    steps: | 
|  | 56 | +      - name: Checkout | 
|  | 57 | +        uses: actions/checkout@v5 | 
|  | 58 | + | 
|  | 59 | +      - name: Setup Node | 
| 30 | 60 |         uses: actions/setup-node@v5 | 
| 31 | 61 |         with: | 
| 32 | 62 |           node-version-file: '.nvmrc' | 
|  | 63 | +          cache: 'yarn' | 
| 33 | 64 | 
 | 
| 34 |  | -      - run: yarn install --immutable --immutable-cache --check-cache | 
| 35 |  | - | 
| 36 |  | -      - name: Run unit tests | 
| 37 |  | -        run: yarn test | 
| 38 |  | - | 
| 39 |  | -  build: | 
| 40 |  | -    name: Build (${{ matrix.name }}) | 
| 41 |  | -    needs: test | 
| 42 |  | -    runs-on:  ${{ matrix.os }} | 
| 43 |  | -    strategy: | 
| 44 |  | -      matrix: | 
| 45 |  | -        include: | 
| 46 |  | -          - name: Android | 
| 47 |  | -            os: ubuntu-latest | 
| 48 |  | -            releaseArgs: --android | 
| 49 |  | - | 
| 50 |  | -          - name: Linux | 
| 51 |  | -            os: ubuntu-latest | 
| 52 |  | -            releaseArgs: --linux64 | 
| 53 |  | - | 
| 54 |  | -          - name: macOS | 
| 55 |  | -            os: macos-11 | 
| 56 |  | -            releaseArgs: --osx64 | 
| 57 |  | - | 
| 58 |  | -          - name: Windows | 
| 59 |  | -            os: windows-2022 | 
| 60 |  | -            releaseArgs: --win64 | 
| 61 |  | -    steps: | 
| 62 |  | -      - uses: actions/checkout@v5 | 
|  | 65 | +      - name: Install dependencies | 
|  | 66 | +        run: yarn install --frozen-lockfile | 
| 63 | 67 | 
 | 
| 64 |  | -      - name: Cache NW.js | 
| 65 |  | -        uses: actions/cache@v4 | 
|  | 68 | +      - name: Install Linux deps (Tauri) | 
|  | 69 | +        run: | | 
|  | 70 | +          sudo apt-get update | 
|  | 71 | +          sudo apt-get install -y \ | 
|  | 72 | +            pkg-config \ | 
|  | 73 | +            libgtk-3-dev \ | 
|  | 74 | +            libwebkit2gtk-4.1-dev \ | 
|  | 75 | +            libayatana-appindicator3-dev \ | 
|  | 76 | +            librsvg2-dev \ | 
|  | 77 | +            libudev-dev \ | 
|  | 78 | +            libssl-dev \ | 
|  | 79 | +            patchelf | 
|  | 80 | +
 | 
|  | 81 | +      - name: Install Rust | 
|  | 82 | +        uses: dtolnay/rust-toolchain@stable | 
|  | 83 | + | 
|  | 84 | +      - name: Build web assets (Vite) | 
|  | 85 | +        run: yarn build | 
|  | 86 | + | 
|  | 87 | +      - name: Build Tauri (Linux) | 
|  | 88 | +        uses: tauri-apps/tauri-action@v0 | 
| 66 | 89 |         with: | 
| 67 |  | -          path: cache/ | 
| 68 |  | -          key: nwjs-${{ inputs.debug_build && 'debug' || 'release' }}-${{ runner.os }} | 
|  | 90 | +          # Use the Tauri CLI directly; the action appends 'build' automatically. | 
|  | 91 | +          tauriScript: yarn tauri | 
|  | 92 | +          # Disable updater.json handling and any release uploads for PR previews. | 
|  | 93 | +          includeUpdaterJson: false | 
|  | 94 | + | 
|  | 95 | +      - name: Inspect Tauri bundle output | 
|  | 96 | +        if: always() | 
|  | 97 | +        run: | | 
|  | 98 | +          echo "Bundle artifacts:" | 
|  | 99 | +          find src-tauri/target/release/bundle -type f \( -name "*.deb" -o -name "*.AppImage" \) -print || true | 
| 69 | 100 | 
 | 
| 70 |  | -      - name: Cache node_modules | 
| 71 |  | -        uses: actions/cache@v4 | 
|  | 101 | +      - name: Upload Linux installers | 
|  | 102 | +        uses: actions/upload-artifact@v4 | 
| 72 | 103 |         with: | 
| 73 |  | -          path: node_modules/ | 
| 74 |  | -          key: node_modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }} | 
|  | 104 | +          name: linux-installers | 
|  | 105 | +          path: | | 
|  | 106 | +            src-tauri/target/release/bundle/**/*.deb | 
|  | 107 | +            src-tauri/target/release/bundle/**/*.AppImage | 
|  | 108 | +          if-no-files-found: warn | 
|  | 109 | +          retention-days: 14 | 
|  | 110 | + | 
|  | 111 | +  tauri-android-preview: | 
|  | 112 | +    name: Tauri Android preview (APK) | 
|  | 113 | +    runs-on: ubuntu-latest | 
|  | 114 | +    needs: node-ci | 
|  | 115 | +    if: ${{ github.event_name == 'pull_request' }} | 
|  | 116 | +    steps: | 
|  | 117 | +      - name: Checkout | 
|  | 118 | +        uses: actions/checkout@v5 | 
| 75 | 119 | 
 | 
| 76 |  | -      - name: Install Node.js | 
|  | 120 | +      - name: Setup Node | 
| 77 | 121 |         uses: actions/setup-node@v5 | 
| 78 | 122 |         with: | 
| 79 | 123 |           node-version-file: '.nvmrc' | 
|  | 124 | +          cache: 'yarn' | 
| 80 | 125 | 
 | 
| 81 |  | -      - name: Install macos dependencies | 
| 82 |  | -        run: | | 
| 83 |  | -          sudo -H pip install setuptools packaging | 
| 84 |  | -          sudo npm install -g [email protected] node-gyp@10 macos-alias | 
| 85 |  | -          yarn --network-timeout 1000000 | 
| 86 |  | -        if: ${{ matrix.name == 'macOs' }} | 
| 87 |  | - | 
| 88 |  | -      - name: Install Java JDK 8 | 
| 89 |  | -        uses: actions/setup-java@v5 | 
| 90 |  | -        if: ${{ matrix.name == 'Android' }} | 
|  | 126 | +      - name: Install dependencies | 
|  | 127 | +        run: yarn install --frozen-lockfile | 
|  | 128 | + | 
|  | 129 | +      - name: Setup Java 17 | 
|  | 130 | +        uses: actions/setup-java@v4 | 
| 91 | 131 |         with: | 
| 92 |  | -          distribution: temurin | 
| 93 |  | -          java-version: '8' | 
|  | 132 | +          distribution: 'temurin' | 
|  | 133 | +          java-version: '17' | 
|  | 134 | + | 
|  | 135 | +      - name: Setup Android SDK | 
|  | 136 | +        uses: android-actions/setup-android@v3 | 
|  | 137 | + | 
|  | 138 | +      - name: Install Rust | 
|  | 139 | +        uses: dtolnay/rust-toolchain@stable | 
|  | 140 | + | 
|  | 141 | +      - name: Install Rust Android targets | 
|  | 142 | +        run: | | 
|  | 143 | +          rustup target add aarch64-linux-android | 
|  | 144 | +          rustup target add armv7-linux-androideabi | 
|  | 145 | +          rustup target add i686-linux-android | 
|  | 146 | +          rustup target add x86_64-linux-android | 
|  | 147 | +
 | 
|  | 148 | +      - name: Build web assets (Vite) | 
|  | 149 | +        run: yarn build | 
| 94 | 150 | 
 | 
| 95 |  | -      - run: yarn install --immutable --immutable-cache --check-cache | 
|  | 151 | +      - name: Initialize Tauri Android project | 
|  | 152 | +        run: yarn tauri android init --ci | 
| 96 | 153 | 
 | 
| 97 |  | -      - run: yarn version --no-git-tag-version --new-version ${{ github.ref_name }} | 
| 98 |  | -        if: ${{ !inputs.debug_build }} | 
|  | 154 | +      - name: Build Tauri Android APK | 
|  | 155 | +        uses: tauri-apps/tauri-action@v0 | 
|  | 156 | +        with: | 
|  | 157 | +          tauriScript: yarn tauri android | 
|  | 158 | +          includeUpdaterJson: false | 
| 99 | 159 | 
 | 
| 100 |  | -      - run: yarn gulp release ${{ matrix.releaseArgs }} | 
| 101 |  | -        if: ${{ !inputs.debug_build && matrix.name != 'Android' }} | 
|  | 160 | +      - name: Inspect Android bundle output | 
|  | 161 | +        if: always() | 
|  | 162 | +        run: | | 
|  | 163 | +          echo "Android APK artifacts:" | 
|  | 164 | +          find src-tauri/gen/android -type f -name "*.apk" -print || true | 
| 102 | 165 | 
 | 
| 103 |  | -      - run: yarn gulp debug-release ${{ matrix.releaseArgs }} | 
| 104 |  | -        if: ${{ inputs.debug_build || matrix.name == 'Android' }} | 
|  | 166 | +      - name: Upload Android APK | 
|  | 167 | +        uses: actions/upload-artifact@v4 | 
|  | 168 | +        with: | 
|  | 169 | +          name: android-apk | 
|  | 170 | +          path: | | 
|  | 171 | +            src-tauri/gen/android/app/build/outputs/apk/**/*.apk | 
|  | 172 | +          if-no-files-found: warn | 
|  | 173 | +          retention-days: 14 | 
|  | 174 | + | 
|  | 175 | +  docker-build: | 
|  | 176 | +    name: Docker build (optional) | 
|  | 177 | +    runs-on: ubuntu-latest | 
|  | 178 | +    needs: node-ci | 
|  | 179 | +    # Only run when called as a reusable workflow AND the caller enabled it | 
|  | 180 | +    if: ${{ github.event_name == 'workflow_call' && inputs.run_docker_build == true }} | 
|  | 181 | +    steps: | 
|  | 182 | +      - name: Checkout | 
|  | 183 | +        uses: actions/checkout@v5 | 
| 105 | 184 | 
 | 
| 106 |  | -      - name: Publish build artifacts | 
|  | 185 | +      - name: Check for Dockerfile | 
|  | 186 | +        id: chk | 
|  | 187 | +        shell: bash | 
|  | 188 | +        run: | | 
|  | 189 | +          if [[ -f Dockerfile ]]; then | 
|  | 190 | +            echo "present=true" >> "$GITHUB_OUTPUT" | 
|  | 191 | +          else | 
|  | 192 | +            echo "present=false" >> "$GITHUB_OUTPUT" | 
|  | 193 | +          fi | 
|  | 194 | +
 | 
|  | 195 | +      - name: Build container image | 
|  | 196 | +        if: ${{ steps.chk.outputs.present == 'true' }} | 
|  | 197 | +        run: | | 
|  | 198 | +          docker build -t betaflight-configurator:ci . | 
|  | 199 | +      - name: Export container (tar) | 
|  | 200 | +        if: ${{ steps.chk.outputs.present == 'true' }} | 
|  | 201 | +        run: | | 
|  | 202 | +          docker save betaflight-configurator:ci -o image.tar | 
|  | 203 | +      - name: Upload image | 
| 107 | 204 |         uses: actions/upload-artifact@v4 | 
|  | 205 | +        if: ${{ steps.chk.outputs.present == 'true' }} | 
| 108 | 206 |         with: | 
| 109 |  | -          name: Betaflight-Configurator${{ inputs.debug_build == 'true' && '-Debug' || '' }}-${{ matrix.name }} | 
| 110 |  | -          path: release/ | 
| 111 |  | -          retention-days: 90 | 
|  | 207 | +          name: docker-image | 
|  | 208 | +          path: image.tar | 
|  | 209 | +          retention-days: 7 | 
0 commit comments