Skip to content

[Single] Build Linux #16

[Single] Build Linux

[Single] Build Linux #16

name: "[Single] Build Linux"
on:
workflow_dispatch:
inputs:
nightly:
description: "Nightly prepare"
required: true
type: boolean
default: false
tag:
description: "Release Tag"
required: true
type: string
arch:
type: choice
description: "build arch target"
required: true
default: "x86_64"
options:
- x86_64
- i686
- aarch64
- armel
- armhf
workflow_call:
inputs:
nightly:
description: "Nightly prepare"
required: true
type: boolean
default: false
tag:
description: "Release Tag"
required: true
type: string
arch:
type: string
description: "build arch target"
required: true
default: "x86_64"
jobs:
build:
runs-on: ubuntu-22.04 # 需要手动升级到 24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust stable
run: |
rustup install stable --profile minimal --no-self-update
rustup default stable
- name: Setup Cargo binstall
if: ${{ inputs.arch != 'x86_64' }}
uses: cargo-bins/cargo-binstall@main
- name: Setup Cross Toolchain
if: ${{ inputs.arch != 'x86_64' }}
shell: bash
run: |
case "${{ inputs.arch }}" in
"i686")
rustup target add i686-unknown-linux-gnu
;;
"aarch64")
rustup target add aarch64-unknown-linux-gnu
;;
"armel")
rustup target add armv7-unknown-linux-gnueabi
;;
"armhf")
rustup target add armv7-unknown-linux-gnueabihf
;;
esac
cargo binstall -y cross
- name: Setup Toolchain
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libxdo-dev libappindicator3-dev librsvg2-dev patchelf openssl
- uses: Swatinem/rust-cache@v2
with:
workspaces: "./backend/"
prefix-key: "rust-stable"
key: ubuntu-latest
shared-key: "release"
- name: Install Node latest
uses: actions/setup-node@v4
with:
node-version: latest
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- name: Install Node.js dependencies
run: |
pnpm i
- name: Prepare sidecars and resources
shell: bash
run: |
case "${{ inputs.arch }}" in
"x86_64")
pnpm check
;;
"i686")
pnpm check --arch ia32 --sidecar-host i686-unknown-linux-gnu
;;
"aarch64")
pnpm check --arch arm64 --sidecar-host aarch64-unknown-linux-gnu
;;
"armel")
pnpm check --arch armel --sidecar-host armv7-unknown-linux-gnueabi
;;
"armhf")
pnpm check --arch arm --sidecar-host armv7-unknown-linux-gnueabihf
;;
esac
- name: Nightly Prepare
if: ${{ inputs.nightly == true }}
run: |
pnpm prepare:nightly
- name: Build UI
run: |
pnpm -F ui build
- name: Tauri build (x86_64)
uses: tauri-apps/tauri-action@v0
if: ${{ inputs.arch == 'x86_64' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
NIGHTLY: ${{ inputs.nightly == true && 'true' || 'false' }}
with:
tagName: ${{ inputs.tag }}
releaseName: "Clash Nyanpasu Dev"
releaseBody: "More new features are now supported."
releaseDraft: false
prerelease: true
tauriScript: pnpm tauri
args: ${{ inputs.nightly == true && '-f nightly -c ./backend/tauri/tauri.nightly.conf.json' || '-f default-meta' }}
- name: Tauri build and upload (cross)
if: ${{ inputs.arch != 'x86_64' }}
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
NIGHTLY: ${{ inputs.nightly == true && 'true' || 'false' }}
run: |
case "${{ inputs.arch }}" in
"i686")
${{ inputs.nightly == true && 'pnpm build:nightly -r cross --target i686-unknown-linux-gnu -b "rpm,deb,updater"' || 'pnpm build -r cross --target i686-unknown-linux-gnu -b "rpm,deb,updater"' }}
;;
"aarch64")
${{ inputs.nightly == true && 'pnpm build:nightly -r cross --target aarch64-unknown-linux-gnu -b "rpm,deb,updater"' || 'pnpm build -r cross --target aarch64-unknown-linux-gnu -b "rpm,deb,updater"' }}
;;
"armel")
${{ inputs.nightly == true && 'pnpm build:nightly -r cross --target armv7-unknown-linux-gnueabi -b "rpm,deb,updater"' || 'pnpm build -r cross --target armv7-unknown-linux-gnueabi -b "rpm,deb,updater"' }}
;;
"armhf")
${{ inputs.nightly == true && 'pnpm build:nightly -r cross --target armv7-unknown-linux-gnueabihf -b "rpm,deb,updater"' || 'pnpm build -r cross --target armv7-unknown-linux-gnueabihf -b "rpm,deb,updater"' }}
;;
esac
find ./backend/target \( -name "*.deb" -o -name "*.rpm" \) | while read file; do
gh release upload ${{ inputs.tag }} "$file" --clobber
done
- name: Calc the archive signature
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME=${{ inputs.tag }}
find ./backend/target \( -name "*.deb" -o -name "*.rpm" \) | while read file; do
sha_file="$file.sha256"
if [[ ! -f "$sha_file" ]]; then
sha256sum "$file" > "$sha_file"
echo "Created checksum file for: $file"
fi
gh release upload $TAG_NAME "$sha_file" --clobber
echo "Uploaded $sha_file to release $TAG_NAME"
done