Files
TeyvatGuide/.github/workflows/debug.yml
2025-12-02 21:29:14 +08:00

133 lines
5.0 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Build Debug for Mac
on:
workflow_dispatch:
inputs:
build-debug:
description: "Build debug version"
required: true
default: true
type: boolean
build-release:
description: "Build release version"
required: true
default: false
type: boolean
jobs:
build-debug-mac:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
settings:
- platform: macos-latest
args: "--target x86_64-apple-darwin"
target: "macos-intel"
artifact: "debug-build-macos-intel"
- platform: macos-latest
args: "--target aarch64-apple-darwin"
target: "macos-arm"
artifact: "debug-build-macos-arm"
runs-on: ${{ matrix.settings.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" | tr -d '\r' > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Add Github RSA
run: |
echo "${{ secrets.KNOWN_GITHUB_RSA }}" >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Test SSH connection
run: ssh -T git@github.com || true
- name: Rust setup
uses: dtolnay/rust-toolchain@stable
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: "./src-tauri -> target"
- name: Add Rust targets(macOS Intel)
if: matrix.settings.target == 'macos-intel'
run: rustup target add x86_64-apple-darwin
- name: Add Rust targets(macOS ARM)
if: matrix.settings.target == 'macos-arm'
run: rustup target add aarch64-apple-darwin
- name: Output toolchain
run: rustup show
- name: Add Offset Conf
run: echo '${{ secrets.YAE_CONF }}' | jq -c . > ./src-tauri/lib/conf.json
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 24.8.0
- name: setup pnpm
uses: pnpm/action-setup@v2
with:
version: 10.23.0
- name: Install frontend dependencies
run: pnpm install
# 获取commit hash后续用这个做文件命名
- name: Get Commit Hash
id: get_commit_hash
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
# Build Debug
- name: Build debug app
if: github.event.inputs.build-debug == 'true'
uses: tauri-apps/tauri-action@dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: ${{ matrix.settings.args }} --debug
- name: Move Debug Intel
if: matrix.settings.target == 'macos-intel' && github.event.inputs.build-debug == 'true'
run: mv src-tauri/target/x86_64-apple-darwin/debug/bundle/dmg/*.dmg TeyvatGuide_${{ env.COMMIT_HASH }}_intel-debug.dmg
- name: Move Debug ARM
if: matrix.settings.target == 'macos-arm' && github.event.inputs.build-debug == 'true'
run: mv src-tauri/target/aarch64-apple-darwin/debug/bundle/dmg/*.dmg TeyvatGuide_${{ env.COMMIT_HASH }}_arm-debug.dmg
- name: Upload Debug Intel
if: matrix.settings.target == 'macos-intel' && github.event.inputs.build-debug == 'true'
uses: actions/upload-artifact@v4
with:
name: debug-macos-intel
path: TeyvatGuide_${{ env.COMMIT_HASH }}_intel-debug.dmg
- name: Upload Debug ARM
if: matrix.settings.target == 'macos-arm' && github.event.inputs.build-debug == 'true'
uses: actions/upload-artifact@v4
with:
name: debug-macos-arm
path: TeyvatGuide_${{ env.COMMIT_HASH }}_arm-debug.dmg
# Build Release
- name: Build app
if: github.event.inputs.build-release == 'true'
uses: tauri-apps/tauri-action@dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: ${{ matrix.settings.args }}
- name: Move Release Intel
if: matrix.settings.target == 'macos-intel' && github.event.inputs.build-release == 'true'
run: mv src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/*.dmg TeyvatGuide_${{ env.COMMIT_HASH }}_intel-release.dmg
- name: Move Release ARM
if: matrix.settings.target == 'macos-arm' && github.event.inputs.build-release == 'true'
run: mv src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/*.dmg TeyvatGuide_${{ env.COMMIT_HASH }}_arm-release.dmg
- name: Upload Release Intel
if: matrix.settings.target == 'macos-intel' && github.event.inputs.build-release
uses: actions/upload-artifact@v4
with:
name: release-macos-intel
path: TeyvatGuide_${{ env.COMMIT_HASH }}_intel-release.dmg
- name: Upload Release ARM
if: matrix.settings.target == 'macos-arm' && github.event.inputs.build-release == 'true'
uses: actions/upload-artifact@v4
with:
name: release-macos-arm
path: TeyvatGuide_${{ env.COMMIT_HASH }}_arm-release.dmg