Skip to content

Refactor code structure for improved readability and maintainability #373

Refactor code structure for improved readability and maintainability

Refactor code structure for improved readability and maintainability #373

Workflow file for this run

name: Build Tauri (All Platforms)
on:
push:
branches: [dev]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
CARGO_NET_RETRY: 3
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- platform: ubuntu-22.04
args: ''
suffix: linux-x64
artifact_name: XFast-Manager-linux-x64
- platform: macos-latest
args: '--target universal-apple-darwin'
suffix: macos-universal
artifact_name: XFast-Manager-macos-universal
- platform: windows-latest
args: ''
suffix: windows-x64
artifact_name: XFast-Manager-windows-portable
name: Build (${{ matrix.suffix }})
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Check if fast build
id: check_fast
shell: bash
run: |
if [[ "${{ github.event.head_commit.message }}" == *"dbuild"* ]]; then
echo "is_fast=true" >> $GITHUB_OUTPUT
echo "🚀 Fast build mode enabled (optimized for speed)"
else
echo "is_fast=false" >> $GITHUB_OUTPUT
echo "📦 Standard build mode (optimized for size)"
fi
- name: Install Linux dependencies
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Add macOS targets
if: matrix.platform == 'macos-latest'
run: |
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 22
cache: 'npm'
- name: Validate version consistency
run: node scripts/validate-version-consistency.mjs
- name: Install JS dependencies
run: npm ci
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies (Fast mode)
if: steps.check_fast.outputs.is_fast == 'true'
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v2-rust-fast"
key: "fast-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}"
cache-on-failure: true
save-if: true
cache-all-crates: true
cache-directories: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
- name: Cache Rust dependencies (Standard mode)
if: steps.check_fast.outputs.is_fast == 'false'
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v2-rust-standard"
key: "standard-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}"
cache-on-failure: false
cache-all-crates: true
cache-directories: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
- name: Set fast build environment
if: steps.check_fast.outputs.is_fast == 'true'
shell: bash
run: |
echo "CARGO_INCREMENTAL=1" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=256" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_LTO=off" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_OPT_LEVEL=1" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_DEBUG=0" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_STRIP=debuginfo" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_PANIC=abort" >> $GITHUB_ENV
echo "RUSTFLAGS=-C embed-bitcode=no" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO=unpacked" >> $GITHUB_ENV
echo "BUILD_MODE=fast" >> $GITHUB_ENV
echo "✅ Fast build environment configured"
- name: Set standard build environment
if: steps.check_fast.outputs.is_fast == 'false'
shell: bash
run: |
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_LTO=fat" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_OPT_LEVEL=3" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_STRIP=debuginfo" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_PANIC=abort" >> $GITHUB_ENV
echo "BUILD_MODE=standard" >> $GITHUB_ENV
- name: Build Tauri
shell: bash
env:
XFAST_ZIBO_GOOGLE_DRIVE_API_KEY: ${{ secrets.XFAST_ZIBO_GOOGLE_DRIVE_API_KEY }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
run: |
echo "🔨 Building for ${{ matrix.suffix }}..."
if [ -n "${{ matrix.args }}" ]; then
npm run tauri:build -- ${{ matrix.args }}
else
npm run tauri:build
fi
- name: Prepare Windows artifact
if: matrix.platform == 'windows-latest'
shell: pwsh
run: |
Rename-Item -Path "target/release/xfastmanager.exe" -NewName "XFast-Manager.exe" -Force
- name: Upload Windows portable artifact
if: matrix.platform == 'windows-latest'
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.artifact_name }}
path: 'target/release/XFast-Manager.exe'
if-no-files-found: error
retention-days: 7
compression-level: 9
- name: Upload Windows MSI artifact
if: matrix.platform == 'windows-latest'
uses: actions/upload-artifact@v6
with:
name: XFast-Manager-windows-msi
path: 'target/release/bundle/msi/*.msi'
if-no-files-found: error
retention-days: 7
compression-level: 9
- name: Upload macOS artifact
if: matrix.platform == 'macos-latest'
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.artifact_name }}
path: 'target/universal-apple-darwin/release/bundle/dmg/*.dmg'
if-no-files-found: error
retention-days: 7
compression-level: 9
- name: Upload Linux artifact
if: matrix.platform == 'ubuntu-22.04'
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.artifact_name }}
path: 'target/release/bundle/appimage/*.AppImage'
if-no-files-found: error
retention-days: 7
compression-level: 9
build-arch-linux:
name: Build (linux-arch-x64)
runs-on: ubuntu-22.04
container:
image: archlinux:latest
env:
APPIMAGE_EXTRACT_AND_RUN: 1
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Check if fast build
id: check_fast_arch
shell: bash
run: |
if [[ "${{ github.event.head_commit.message }}" == *"dbuild"* ]]; then
echo "is_fast=true" >> $GITHUB_OUTPUT
echo "🚀 Fast build mode enabled (optimized for speed)"
else
echo "is_fast=false" >> $GITHUB_OUTPUT
echo "📦 Standard build mode (optimized for size)"
fi
- name: Install Arch Linux dependencies
shell: bash
run: |
pacman-key --init
pacman-key --populate archlinux
pacman -Syu --noconfirm --needed \
base-devel \
curl \
git \
openssl \
pkgconf \
gtk3 \
webkit2gtk-4.1 \
libappindicator-gtk3 \
librsvg \
patchelf
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 22
cache: 'npm'
- name: Validate version consistency
run: node scripts/validate-version-consistency.mjs
- name: Install JS dependencies
run: npm ci
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies (Fast mode)
if: steps.check_fast_arch.outputs.is_fast == 'true'
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v2-rust-arch-fast"
key: "fast-archlinux-${{ hashFiles('**/Cargo.lock') }}"
cache-on-failure: true
save-if: true
cache-all-crates: true
cache-directories: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
- name: Cache Rust dependencies (Standard mode)
if: steps.check_fast_arch.outputs.is_fast == 'false'
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v2-rust-arch-standard"
key: "standard-archlinux-${{ hashFiles('**/Cargo.lock') }}"
cache-on-failure: false
cache-all-crates: true
cache-directories: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
- name: Set fast build environment
if: steps.check_fast_arch.outputs.is_fast == 'true'
shell: bash
run: |
echo "CARGO_INCREMENTAL=1" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=256" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_LTO=off" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_OPT_LEVEL=1" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_DEBUG=0" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_STRIP=debuginfo" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_PANIC=abort" >> $GITHUB_ENV
echo "RUSTFLAGS=-C embed-bitcode=no" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO=unpacked" >> $GITHUB_ENV
echo "BUILD_MODE=fast" >> $GITHUB_ENV
echo "✅ Fast build environment configured"
- name: Set standard build environment
if: steps.check_fast_arch.outputs.is_fast == 'false'
shell: bash
run: |
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_LTO=fat" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_OPT_LEVEL=3" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_STRIP=debuginfo" >> $GITHUB_ENV
echo "CARGO_PROFILE_RELEASE_PANIC=abort" >> $GITHUB_ENV
echo "BUILD_MODE=standard" >> $GITHUB_ENV
- name: Build frontend
shell: bash
run: npm run build
- name: Build Arch Linux binary
shell: bash
env:
XFAST_ZIBO_GOOGLE_DRIVE_API_KEY: ${{ secrets.XFAST_ZIBO_GOOGLE_DRIVE_API_KEY }}
run: |
echo "🔨 Building native Arch Linux binary..."
cargo build --manifest-path src-tauri/Cargo.toml --release
- name: Build Arch Linux AppImage
id: arch_appimage
continue-on-error: true
shell: bash
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
RUST_LOG: tauri_bundler=trace
run: |
if [[ "${{ github.event.head_commit.message }}" != *"archappimage"* ]]; then
echo "Skipping experimental Arch AppImage build. Add 'archappimage' to the commit message to enable it."
exit 0
fi
echo "🔨 Building Arch Linux AppImage (non-blocking experimental step)..."
npm run tauri:build -- --bundles appimage 2>&1 | tee arch-appimage-build.log
- name: Package Arch Linux artifact
shell: bash
run: |
mkdir -p artifacts
cp target/release/xfastmanager artifacts/XFast-Manager
tar -C artifacts -czf target/release/XFast-Manager-linux-arch-x64.tar.gz XFast-Manager
- name: Upload Arch Linux tar.gz artifact
uses: actions/upload-artifact@v6
with:
name: XFast-Manager-linux-arch-x64
path: 'target/release/XFast-Manager-linux-arch-x64.tar.gz'
if-no-files-found: error
retention-days: 7
compression-level: 9
- name: Upload Arch Linux AppImage artifact
if: steps.arch_appimage.outcome != 'skipped'
uses: actions/upload-artifact@v6
with:
name: XFast-Manager-linux-arch-x64-appimage
path: 'target/release/bundle/appimage/*.AppImage'
if-no-files-found: ignore
retention-days: 7
compression-level: 9
- name: Upload Arch Linux AppImage debug artifacts
if: steps.arch_appimage.outcome == 'failure'
uses: actions/upload-artifact@v6
with:
name: XFast-Manager-linux-arch-x64-appimage-debug
path: |
arch-appimage-build.log
target/release/bundle/appimage/build_appimage.sh
target/release/bundle/appimage/*.AppImage
target/release/bundle/appimage/*.AppDir/**
/github/home/.cache/tauri/linuxdeploy*
if-no-files-found: ignore
retention-days: 7
compression-level: 9