Skip to content

Commit 472afa6

Browse files
ci: refactor to use composite actions for shared workflows
1 parent 91010d5 commit 472afa6

5 files changed

Lines changed: 159 additions & 90 deletions

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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

.github/workflows/build-android-app.yml

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ on:
2020
- 'Gemfile*'
2121
- 'package*.json'
2222
- '.github/workflows/build-android-app.yml'
23+
- '.github/actions/setup-tauri-build/**'
2324

2425
# Cancel in-progress builds when a newer one is triggered
2526
concurrency:
@@ -37,50 +38,10 @@ jobs:
3738
ANDROID_NDK_HOME: /opt/homebrew/share/android-commandlinetools/ndk/28.2.13676358
3839
NDK_HOME: /opt/homebrew/share/android-commandlinetools/ndk/28.2.13676358
3940
steps:
40-
- name: Checkout repository
41-
uses: actions/checkout@v6
41+
- name: Setup Tauri build environment
42+
uses: ./.github/actions/setup-tauri-build
4243
with:
43-
fetch-depth: 1
44-
45-
- name: Setup Ruby
46-
uses: ruby/setup-ruby@v1
47-
with:
48-
ruby-version: '4.0.1'
49-
50-
- name: Install Ruby dependencies
51-
run: bundle install
52-
53-
- name: Setup Node.js
54-
uses: actions/setup-node@v6
55-
with:
56-
node-version: '24'
57-
58-
- name: Install npm dependencies
59-
run: npm ci
60-
61-
- name: Setup Rust
62-
uses: dtolnay/rust-toolchain@stable
63-
with:
64-
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android
65-
66-
- name: Cache Task checksums
67-
uses: actions/cache@v5
68-
with:
69-
path: .task
70-
key: ${{ runner.os }}-task-v1
71-
restore-keys: |
72-
${{ runner.os }}-task-
73-
74-
- name: Cache Android build artifacts
75-
uses: actions/cache@v5
76-
with:
77-
path: src-tauri/gen/android/app/build
78-
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') }}
79-
restore-keys: |
80-
${{ runner.os }}-android-build-
81-
82-
- name: Install Task
83-
uses: go-task/setup-task@v1
44+
platform: android
8445

8546
- name: Setup Android signing
8647
env:
@@ -93,10 +54,9 @@ jobs:
9354
echo "storeFile=$RUNNER_TEMP/keystore.jks" >> keystore.properties
9455
9556
- name: Build and upload to Google Play
96-
run: |
97-
export PATH="$JAVA_HOME/bin:$PATH"
98-
task android:testflight
57+
run: task android:testflight
9958
env:
59+
PATH: ${{ env.JAVA_HOME }}/bin:${{ env.PATH }}
10060
FASTLANE_OPT_OUT_USAGE: 1
10161
SUPPLY_JSON_KEY_DATA: ${{ secrets.GOOGLE_PLAY_JSON_KEY }}
10262
GOOGLE_PLAY_TRACK: ${{ vars.GOOGLE_PLAY_TRACK || 'alpha' }}

.github/workflows/build-ios-app.yml

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ on:
2020
- 'Gemfile*'
2121
- 'package*.json'
2222
- '.github/workflows/build-ios-app.yml'
23+
- '.github/actions/setup-tauri-build/**'
2324

2425
# Cancel in-progress builds when a newer one is triggered
2526
concurrency:
@@ -33,57 +34,17 @@ jobs:
3334
BUNDLE_FROZEN: "true"
3435
RUBYOPT: "-W0"
3536
steps:
36-
- name: Checkout repository
37-
uses: actions/checkout@v6
37+
- name: Setup Tauri build environment
38+
uses: ./.github/actions/setup-tauri-build
3839
with:
39-
fetch-depth: 1
40-
41-
- name: Setup Ruby
42-
uses: ruby/setup-ruby@v1
43-
with:
44-
ruby-version: '4.0.1'
45-
46-
- name: Install Ruby dependencies
47-
run: bundle install
48-
49-
- name: Setup Node.js
50-
uses: actions/setup-node@v6
51-
with:
52-
node-version: '24'
53-
54-
- name: Install npm dependencies
55-
run: npm ci
56-
57-
- name: Setup Rust
58-
uses: dtolnay/rust-toolchain@stable
59-
with:
60-
targets: aarch64-apple-ios,aarch64-apple-ios-sim,x86_64-apple-ios
40+
platform: ios
6141

6242
- name: Ensure Tauri iOS dependencies
6343
run: |
6444
for pkg in xcodegen libimobiledevice; do
6545
brew list "$pkg" &>/dev/null || brew install "$pkg"
6646
done
6747
68-
- name: Cache Task checksums
69-
uses: actions/cache@v5
70-
with:
71-
path: .task
72-
key: ${{ runner.os }}-task-v1
73-
restore-keys: |
74-
${{ runner.os }}-task-
75-
76-
- name: Cache iOS build artifacts
77-
uses: actions/cache@v5
78-
with:
79-
path: src-tauri/gen/apple/build
80-
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') }}
81-
restore-keys: |
82-
${{ runner.os }}-ios-build-
83-
84-
- name: Install Task
85-
uses: go-task/setup-task@v1
86-
8748
- name: Build and upload to TestFlight
8849
run: task ios:testflight
8950
env:

.github/workflows/release-please.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010

1111
jobs:
1212
release-please:
13-
runs-on: ubuntu-latest
13+
runs-on: blacksmith-4vcpu-ubuntu-2404
1414
outputs:
1515
release_created: ${{ steps.release.outputs.release_created }}
1616
tag_name: ${{ steps.release.outputs.tag_name }}

docs/architecture.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,55 @@ The Rust code is minimal because it only handles database operations. Alpine.js
856856

857857
## CI/CD Configuration
858858

859+
### Shared Build Environment (Composite Action)
860+
861+
Both iOS and Android workflows use a shared composite action for environment setup:
862+
863+
**Location**: `.github/actions/setup-tauri-build/action.yml`
864+
865+
**Usage**:
866+
```yaml
867+
- name: Setup Tauri build environment
868+
uses: ./.github/actions/setup-tauri-build
869+
with:
870+
platform: ios # or 'android'
871+
```
872+
873+
**What it does**:
874+
- Checks out repository
875+
- Sets up Ruby 4.0.1 and installs dependencies (Fastlane)
876+
- Sets up Node.js 24 and runs `npm ci`
877+
- Installs Rust with platform-specific targets
878+
- Caches Task checksums and platform build artifacts
879+
- Installs Task runner
880+
881+
**Inputs**:
882+
| Input | Required | Default | Description |
883+
|-------|----------|---------|-------------|
884+
| `platform` | Yes | - | `ios` or `android` |
885+
| `ruby-version` | No | `4.0.1` | Ruby version |
886+
| `node-version` | No | `24` | Node.js version |
887+
888+
**Outputs**:
889+
| Output | Description |
890+
|--------|-------------|
891+
| `cache-hit` | Whether build artifact cache was hit |
892+
893+
### Blacksmith Runners
894+
895+
The `release-please.yml` workflow uses [Blacksmith](https://blacksmith.sh) runners for faster CI execution:
896+
897+
```yaml
898+
runs-on: blacksmith-4vcpu-ubuntu-2404
899+
```
900+
901+
**Benefits**:
902+
- No queue wait time
903+
- 50% cost savings vs GitHub Actions
904+
- 4x faster cache operations
905+
906+
**Note**: iOS and Android builds still use the self-hosted macOS runner (`mini`) because they require Xcode and the Android SDK.
907+
859908
### Self-Hosted Runner DNS (MinIO)
860909

861910
The iOS CI/CD pipeline uses Fastlane Match with MinIO (S3-compatible) storage for code signing certificates. The self-hosted runner `mini` requires a static hosts entry to ensure reliable DNS resolution for the MinIO API endpoint.

0 commit comments

Comments
 (0)