vibetunnel/.github/workflows/build-tauri.yml

174 lines
No EOL
5.3 KiB
YAML

name: Build Tauri App
on:
push:
branches: [ main ]
paths:
- 'tauri/**'
- '.github/workflows/build-tauri.yml'
pull_request:
branches: [ main ]
paths:
- 'tauri/**'
- '.github/workflows/build-tauri.yml'
workflow_dispatch:
jobs:
# Check if we should run the build
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
tauri: ${{ steps.filter.outputs.tauri }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
tauri:
- 'tauri/**'
- '.github/workflows/build-tauri.yml'
build:
needs: changes
if: ${{ needs.changes.outputs.tauri == 'true' || github.event_name == 'workflow_dispatch' }}
strategy:
fail-fast: false
matrix:
include:
- platform: 'macos-latest'
target: 'x86_64-apple-darwin'
- platform: 'macos-latest'
target: 'aarch64-apple-darwin'
- platform: 'blacksmith-8vcpu-ubuntu-2404-arm'
target: 'aarch64-unknown-linux-gnu'
- platform: 'windows-latest'
target: 'x86_64-pc-windows-msvc'
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
cache-dependency-path: web/pnpm-lock.yaml
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Python setuptools
run: pip install setuptools
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup Rust target
if: startsWith(matrix.platform, 'blacksmith') || startsWith(matrix.platform, 'ubuntu')
run: |
rustup target add ${{ matrix.target }}
# Set appropriate linker based on target
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=gcc" >> $GITHUB_ENV
else
echo "CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=gcc" >> $GITHUB_ENV
fi
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './tauri/src-tauri -> target'
- name: Install dependencies (Linux)
if: startsWith(matrix.platform, 'blacksmith') || startsWith(matrix.platform, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev libpam0g-dev
- name: Install dependencies (Windows)
if: matrix.platform == 'windows-latest'
run: |
choco install llvm -y
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: ${{ startsWith(matrix.platform, 'blacksmith') && 'actions/cache@v4' || 'actions/cache@v3' }}
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install web dependencies
working-directory: ./web
run: |
# Install dependencies (without frozen lockfile due to config differences)
pnpm install
# Rebuild native modules for the target platform
pnpm rebuild
- name: Build web assets
working-directory: ./web
run: pnpm run build
- name: Cache tauri-cli
id: cache-tauri
uses: ${{ startsWith(matrix.platform, 'blacksmith') && 'actions/cache@v4' || 'actions/cache@v3' }}
with:
path: ~/.cargo/bin/cargo-tauri
key: ${{ runner.os }}-tauri-cli-2.0
- name: Install tauri-cli
if: steps.cache-tauri.outputs.cache-hit != 'true'
run: cargo install tauri-cli --version "^2.0.0" --locked
- name: Build Tauri app
working-directory: ./tauri/src-tauri
run: cargo tauri build --target ${{ matrix.target }} --ci
- name: Upload artifacts (macOS)
if: matrix.platform == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: vibetunnel-${{ matrix.target }}
path: |
tauri/src-tauri/target/${{ matrix.target }}/release/bundle/dmg/*.dmg
tauri/src-tauri/target/${{ matrix.target }}/release/bundle/macos/*.app
if-no-files-found: error
- name: Upload artifacts (Linux)
if: startsWith(matrix.platform, 'blacksmith') || startsWith(matrix.platform, 'ubuntu')
uses: actions/upload-artifact@v4
with:
name: vibetunnel-${{ matrix.target }}
path: |
tauri/src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
tauri/src-tauri/target/${{ matrix.target }}/release/bundle/appimage/*.AppImage
if-no-files-found: error
- name: Upload artifacts (Windows)
if: matrix.platform == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: vibetunnel-${{ matrix.target }}
path: |
tauri/src-tauri/target/${{ matrix.target }}/release/bundle/msi/*.msi
tauri/src-tauri/target/${{ matrix.target }}/release/bundle/nsis/*.exe
if-no-files-found: error