Skip to content

Commit 02c04e4

Browse files
authored
Tauri (#4680)
1 parent 93db9fa commit 02c04e4

26 files changed

+6889
-168
lines changed
Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,66 @@
11
name: Artifact links comments creator
22
on:
33
workflow_run:
4-
workflows: ["PR"]
4+
workflows: ["CI"]
55
types: [completed]
66

77
jobs:
88
artifacts-url-comments:
99
name: Add artifact links to PR and issues
1010
runs-on: ubuntu-latest
11+
# Only run if the CI workflow was triggered by a pull_request and succeeded
12+
if: >
13+
github.event.workflow_run.event == 'pull_request' &&
14+
github.event.workflow_run.conclusion == 'success'
15+
permissions:
16+
pull-requests: write
17+
actions: read
1118
steps:
12-
- name: Add artifact links to PR and issues
13-
uses: tonyhallett/[email protected]
14-
env:
15-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
- name: 'Download artifact metadata'
20+
uses: actions/github-script@v7
21+
id: artifacts
1622
with:
17-
prefix: "Do you want to test this code? Here you have an automated build:"
18-
suffix: "WARNING: It may be unstable and result in corrupted configurations or data loss. Use only for testing!"
19-
format: name
20-
addTo: pull
23+
script: |
24+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
run_id: context.payload.workflow_run.id,
28+
});
29+
30+
let links = [];
31+
for (const artifact of artifacts.data.artifacts) {
32+
const url = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.payload.workflow_run.id}/artifacts/${artifact.id}`;
33+
links.push(`- [${artifact.name}](${url}) (${(artifact.size_in_bytes / 1024 / 1024).toFixed(2)} MB)`);
34+
}
35+
36+
core.setOutput('artifact_links', links.join('\n'));
37+
core.setOutput('has_artifacts', String(links.length > 0));
38+
39+
- name: 'Comment on PR'
40+
if: steps.artifacts.outputs.has_artifacts == 'true'
41+
uses: actions/github-script@v7
42+
with:
43+
script: |
44+
// Get PR number from the workflow_run event
45+
const pullRequests = context.payload.workflow_run.pull_requests;
46+
if (!pullRequests || pullRequests.length === 0) {
47+
console.log('No pull request associated with this workflow run');
48+
return;
49+
}
50+
const prNumber = pullRequests[0].number;
51+
const artifactLinks = `${{ steps.artifacts.outputs.artifact_links }}`;
52+
53+
const body = `## 🚀 Build Artifacts Ready!
54+
55+
Do you want to test this code? Here you have automated builds:
56+
57+
${artifactLinks}
58+
59+
⚠️ **WARNING:** These are preview builds and may be unstable. They could result in corrupted configurations or data loss. Use only for testing!`;
60+
61+
await github.rest.issues.createComment({
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
issue_number: prNumber,
65+
body: body
66+
});

.github/workflows/ci-test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: CI Test
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
run_docker_build:
7+
description: "Also try a Docker build if a Dockerfile exists"
8+
required: false
9+
default: "false"
10+
type: choice
11+
options: ["false", "true"]
12+
13+
jobs:
14+
call-ci:
15+
uses: ./.github/workflows/ci.yml
16+
with:
17+
run_docker_build: ${{ github.event.inputs.run_docker_build == 'true' }}

.github/workflows/ci.yml

Lines changed: 174 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,209 @@
1-
# Builds Betaflight Configurator on Windows, Android, Linux and macOS platforms.
2-
#
3-
# After building, artifacts are released to a separate repository.
4-
51
name: CI
62

3+
# Run on PRs to show artifacts, and keep callable for reuse.
74
on:
5+
pull_request:
6+
push:
7+
branches: [ tauri ]
88
workflow_call:
99
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'
1312
required: false
13+
default: false
1414
type: boolean
1515

1616
jobs:
17-
test:
18-
name: Test
17+
node-ci:
18+
name: Lint, test, and build (Node)
1919
runs-on: ubuntu-latest
2020
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
2241

23-
- name: Cache node_modules
24-
uses: actions/cache@v4
42+
- name: Upload web dist
43+
uses: actions/upload-artifact@v4
2544
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
2849

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
3060
uses: actions/setup-node@v5
3161
with:
3262
node-version-file: '.nvmrc'
63+
cache: 'yarn'
3364

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
6367

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
6689
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
69100
70-
- name: Cache node_modules
71-
uses: actions/cache@v4
101+
- name: Upload Linux installers
102+
uses: actions/upload-artifact@v4
72103
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
75119

76-
- name: Install Node.js
120+
- name: Setup Node
77121
uses: actions/setup-node@v5
78122
with:
79123
node-version-file: '.nvmrc'
124+
cache: 'yarn'
80125

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
91131
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
94150

95-
- run: yarn install --immutable --immutable-cache --check-cache
151+
- name: Initialize Tauri Android project
152+
run: yarn tauri android init --ci
96153

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
99159

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
102165
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
105184

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
107204
uses: actions/upload-artifact@v4
205+
if: ${{ steps.chk.outputs.present == 'true' }}
108206
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

Comments
 (0)