|
| 1 | +name: Setup Build Environment |
| 2 | +description: 'Sets up Ruby, Node.js, Rust, and Task for Tauri iOS/Android builds' |
| 3 | + |
| 4 | +inputs: |
| 5 | + platform: |
| 6 | + description: 'Target platform: ios or android' |
| 7 | + required: true |
| 8 | + ruby-version: |
| 9 | + description: 'Ruby version to install (overrides RUBY_VERSION env var)' |
| 10 | + required: false |
| 11 | + default: '' |
| 12 | + node-version: |
| 13 | + description: 'Node.js version to install (overrides NODE_VERSION env var)' |
| 14 | + required: false |
| 15 | + default: '' |
| 16 | + |
| 17 | +outputs: |
| 18 | + cache-hit: |
| 19 | + description: 'Whether the build artifact cache was hit' |
| 20 | + value: ${{ steps.cache-build.outputs.cache-hit }} |
| 21 | + |
| 22 | +runs: |
| 23 | + using: 'composite' |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v6 |
| 27 | + with: |
| 28 | + fetch-depth: 1 |
| 29 | + |
| 30 | + - name: Setup Ruby |
| 31 | + uses: ruby/setup-ruby@v1 |
| 32 | + with: |
| 33 | + ruby-version: ${{ inputs.ruby-version || env.RUBY_VERSION || '4.0.1' }} |
| 34 | + |
| 35 | + - name: Install Ruby dependencies |
| 36 | + shell: bash |
| 37 | + run: bundle install |
| 38 | + |
| 39 | + - name: Setup Node.js |
| 40 | + uses: actions/setup-node@v6 |
| 41 | + with: |
| 42 | + node-version: ${{ inputs.node-version || env.NODE_VERSION || '24' }} |
| 43 | + |
| 44 | + - name: Install npm dependencies |
| 45 | + shell: bash |
| 46 | + run: npm ci |
| 47 | + |
| 48 | + - name: Setup Rust (iOS) |
| 49 | + if: inputs.platform == 'ios' |
| 50 | + uses: dtolnay/rust-toolchain@stable |
| 51 | + with: |
| 52 | + targets: aarch64-apple-ios,aarch64-apple-ios-sim,x86_64-apple-ios |
| 53 | + |
| 54 | + - name: Setup Rust (Android) |
| 55 | + if: inputs.platform == 'android' |
| 56 | + uses: dtolnay/rust-toolchain@stable |
| 57 | + with: |
| 58 | + targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android |
| 59 | + |
| 60 | + - name: Cache Task checksums |
| 61 | + uses: actions/cache@v5 |
| 62 | + with: |
| 63 | + path: .task |
| 64 | + key: ${{ runner.os }}-task-v1 |
| 65 | + restore-keys: | |
| 66 | + ${{ runner.os }}-task- |
| 67 | +
|
| 68 | + - name: Cache iOS build artifacts |
| 69 | + if: inputs.platform == 'ios' |
| 70 | + id: cache-build-ios |
| 71 | + uses: actions/cache@v5 |
| 72 | + with: |
| 73 | + path: src-tauri/gen/apple/build |
| 74 | + key: ${{ runner.os }}-ios-build-${{ hashFiles('src-tauri/src/**/*.rs', 'src-tauri/Cargo.toml', 'src-tauri/Cargo.lock', 'src-tauri/tauri.conf.json', 'src-tauri/dist/**/*', 'src-tauri/icons/icon.png', 'fastlane/Fastfile', 'fastlane/Appfile') }} |
| 75 | + restore-keys: | |
| 76 | + ${{ runner.os }}-ios-build- |
| 77 | +
|
| 78 | + - name: Cache Android build artifacts |
| 79 | + if: inputs.platform == 'android' |
| 80 | + id: cache-build-android |
| 81 | + uses: actions/cache@v5 |
| 82 | + with: |
| 83 | + path: src-tauri/gen/android/app/build |
| 84 | + key: ${{ runner.os }}-android-build-${{ hashFiles('src-tauri/src/**/*.rs', 'src-tauri/Cargo.toml', 'src-tauri/Cargo.lock', 'src-tauri/tauri.conf.json', 'src-tauri/dist/**/*', 'src-tauri/icons/icon.png', 'fastlane/Fastfile', 'fastlane/Appfile') }} |
| 85 | + restore-keys: | |
| 86 | + ${{ runner.os }}-android-build- |
| 87 | +
|
| 88 | + - name: Set cache-hit output |
| 89 | + id: cache-build |
| 90 | + shell: bash |
| 91 | + run: | |
| 92 | + if [[ "${{ inputs.platform }}" == "ios" ]]; then |
| 93 | + echo "cache-hit=${{ steps.cache-build-ios.outputs.cache-hit }}" >> $GITHUB_OUTPUT |
| 94 | + else |
| 95 | + echo "cache-hit=${{ steps.cache-build-android.outputs.cache-hit }}" >> $GITHUB_OUTPUT |
| 96 | + fi |
| 97 | +
|
| 98 | + - name: Install Task |
| 99 | + uses: go-task/setup-task@v1 |
0 commit comments