Skip to content

[Single] Build macOS #12

[Single] Build macOS

[Single] Build macOS #12

name: '[Single] Build macOS'
on:
workflow_dispatch:
inputs:
aarch64:
description: 'Build aarch64 pkg'
required: true
type: boolean
default: false
nightly:
description: 'Nightly prepare'
required: true
type: boolean
default: false
tag:
description: 'Release Tag'
required: true
type: string
workflow_call:
inputs:
aarch64:
description: 'Build aarch64 pkg'
required: true
type: boolean
default: false
nightly:
description: 'Nightly prepare'
required: true
type: boolean
default: false
tag:
description: 'Release Tag'
required: true
type: string
jobs:
build:
runs-on: 'macos-13'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 14
- name: install Rust stable
run: |
rustup install stable --profile minimal --no-self-update
rustup default stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: './backend/'
prefix-key: 'rust-stable'
key: 'macos-latest'
shared-key: 'release'
- name: Install Rust intel target
if: ${{ inputs.aarch64 == false }}
run: |
rustup target add x86_64-apple-darwin
- name: Install Rust aarch64 target
if: ${{ inputs.aarch64 == true }}
run: |
rustup target add aarch64-apple-darwin
- 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: Pnpm install
shell: bash
run: |
pnpm i
- name: Download Sidecars aarch64
if: ${{ inputs.aarch64 == true }}
run: pnpm check --arch arm64 --sidecar-host aarch64-apple-darwin
- name: Download Sidecars x64
if: ${{ inputs.aarch64 == false }}
run: pnpm check --arch x64 --sidecar-host x86_64-apple-darwin
- name: Nightly Prepare
if: ${{ inputs.nightly == true }}
run: |
pnpm prepare:nightly
- name: Build UI
run: |
pnpm -F ui build
- name: Build Clash Nyanpasu (Stable)
if: ${{ inputs.nightly == false }}
run: |
pnpm tauri build --verbose -f default-meta ${{ inputs.aarch64 == true && '--target aarch64-apple-darwin' || '--target x86_64-apple-darwin' }}
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' }}
NODE_OPTIONS: '--max_old_space_size=4096'
- name: Build Clash Nyanpasu (Nightly)
if: ${{ inputs.nightly == true }}
run: |
pnpm build:nightly --verbose ${{ inputs.aarch64 == true && '--target aarch64-apple-darwin' || '--target x86_64-apple-darwin' }}
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' }}
NODE_OPTIONS: '--max_old_space_size=4096'
- name: Upload to release
shell: bash
run: |
find ./backend/target \( -name "*.dmg" -o -name "*.sig" -o -name "*.tar.gz" \) | while read file; do
echo "Uploading $file to release"
gh release upload ${{ inputs.tag }} "$file" --clobber
done
- name: Upload to Github Artifact
uses: actions/upload-artifact@v4
with:
name: Clash.Nyanpasu-macOS-${{ inputs.aarch64 == true && 'aarch64' || 'amd64' }}
path: |
./backend/target/**/*.dmg