Files
Pake/.github/workflows/single-app.yaml
2025-08-29 18:05:52 +08:00

160 lines
4.6 KiB
YAML
Vendored

name: Build Single Popular App
env:
NODE_VERSION: '22'
PNPM_VERSION: '10.15.0'
on:
workflow_dispatch:
inputs:
name:
description: "App Name"
required: true
default: "twitter"
title:
description: "App Title"
required: true
default: "Twitter"
name_zh:
description: "App Name in Chinese"
required: true
default: "推特"
url:
description: "App URL"
required: true
default: "https://twitter.com/"
workflow_call:
inputs:
name:
description: "App Name"
type: string
required: true
default: "twitter"
title:
description: "App Title"
required: true
type: string
default: "Twitter"
name_zh:
description: "App Name in Chinese"
required: true
type: string
default: "推特"
url:
description: "App URL"
required: true
type: string
default: "https://twitter.com/"
jobs:
build:
name: ${{ inputs.title }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build: [linux, macos, windows]
include:
- build: linux
os: ubuntu-latest
rust: stable
- build: windows
os: windows-latest
rust: stable-x86_64-msvc
- build: macos
os: macos-latest
rust: stable
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- name: Setup Node.js Environment
uses: ./.github/actions/setup-env
with:
mode: node-only
- name: Rust cache restore
uses: actions/cache/restore@v4.2.0
id: cache_store
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Config App
env:
NAME: ${{ inputs.name }}
TITLE: ${{ inputs.title }}
NAME_ZH: ${{ inputs.name_zh }}
URL: ${{ inputs.url }}
run: pnpm run build:config
- name: Build for Linux
if: matrix.os == 'ubuntu-latest'
timeout-minutes: 15
run: |
pnpm run tauri build
mkdir -p output/linux
mv src-tauri/target/release/bundle/deb/*.deb output/linux/${{inputs.title}}_`arch`.deb
mv src-tauri/target/release/bundle/appimage/*.AppImage output/linux/"${{inputs.title}}"_`arch`.AppImage
- name: Build for macOS
if: matrix.os == 'macos-latest'
timeout-minutes: 20
run: |
pnpm run build:mac
mkdir -p output/macos
mv src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg output/macos/"${{inputs.title}}".dmg
- name: Build for Windows
if: matrix.os == 'windows-latest'
timeout-minutes: 15
run: |
pnpm run build
New-Item -Path "output\windows" -ItemType Directory -Force
$msiFiles = Get-ChildItem -Path "src-tauri\target\release\bundle\msi\*.msi" -ErrorAction SilentlyContinue
if ($msiFiles) {
Move-Item -Path $msiFiles[0].FullName -Destination "output\windows\${{inputs.title}}_x64.msi"
} else {
Write-Error "No MSI files found at: src-tauri\target\release\bundle\msi\"
Get-ChildItem -Path "src-tauri\target\" -Recurse -Name "*.msi" | Write-Host
exit 1
}
git checkout -- src-tauri/Cargo.lock
- name: Rust cache store
uses: actions/cache/save@v4.2.0
if: steps.cache_store.outputs.cache-hit != 'true'
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.title }}-${{ matrix.build }}
path: output/*/*.*
retention-days: 3
- name: Upload to release
uses: ncipollo/release-action@v1 # cspell:disable-line
if: startsWith(github.ref, 'refs/tags/')
with:
allowUpdates: true
artifacts: "output/*/*.*"
token: ${{ secrets.GITHUB_TOKEN }}