refactor: autobuild.yml

This commit is contained in:
TaurusXin 2025-10-04 15:36:49 +08:00
parent 0f56a0160e
commit 1d384cb185

View File

@ -7,61 +7,108 @@ on:
branches: [ main, dev ] branches: [ main, dev ]
jobs: jobs:
build: # ----------------------------------------------------------------------
strategy: # 1. Linux (Ubuntu)
matrix: # ----------------------------------------------------------------------
os: [ubuntu-latest, macos-latest, windows-latest] job_linux:
build_config: [Release] name: Linux Build
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
env:
VCPKG_TRIPLET: x64-windows-static
steps: steps:
- name: 检出代码 - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Install Dependencies - Ubuntu - name: Install Dependencies
if: runner.os == 'Linux'
run: | run: |
sudo apt update sudo apt-get update
sudo apt install -y build-essential cmake libtag1-dev sudo apt-get install -y build-essential cmake libtag1-dev
- name: Install Dependencies - macOS - name: Configure CMake
if: runner.os == 'macOS'
run: | run: |
brew install git cmake taglib cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=Release \
-S ${{github.workspace}}
- name: Install Dependencies - Windows - name: Build
run: cmake --build ${{github.workspace}}/build --config Release
- name: Upload Linux Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact-linux
path: ${{github.workspace}}/build/ncmdump
# ----------------------------------------------------------------------
# 2. macOS Build
# ----------------------------------------------------------------------
job_macos:
name: macOS Build (Brew)
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Install Dependencies
run: |
brew install taglib
- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=Release \
-S ${{github.workspace}}
- name: 构建项目
run: cmake --build ${{github.workspace}}/build --config Release
- name: 上传 macOS 产物
uses: actions/upload-artifact@v4
with:
name: build-artifact-macos
path: ${{github.workspace}}/build/ncmdump
# ----------------------------------------------------------------------
# 3. Windows Build
# ----------------------------------------------------------------------
job_windows:
name: Windows Build
runs-on: windows-latest
env:
VCPKG_TRIPLET: x64-windows-static
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Install Dependencies
uses: lukka/run-vcpkg@v11 uses: lukka/run-vcpkg@v11
id: Vcpkg
with: with:
vcpkgJsonGlob: '**/vcpkg.json' vcpkgJsonGlob: '**/vcpkg.json'
vcpkgTriplet: ${{ env.VCPKG_TRIPLET }} vcpkgTriplet: ${{ env.VCPKG_TRIPLET }}
# ----------------------------------------------------------------------
# CMake Configuration
# ----------------------------------------------------------------------
- name: Configure CMake - name: Configure CMake
run: | run: |
BUILD_DIR=${{ github.workspace }}/build $toolchainFile = "${{ steps.vcpkg.outputs.vcpkgToolchainFile }}"
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=${{ matrix.build_config }} -S ${{ github.workspace }}"
if [ "$RUNNER_OS" == "Windows" ]; then cmake -B ${{github.workspace}}/build `
CMAKE_TOOLCHAIN_FILE_PATH=$(echo ${{ steps.vcpkg.outputs.vcpkgToolchainFile }}) -DCMAKE_TOOLCHAIN_FILE=$toolchainFile `
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE_PATH}" -DVCPKG_TARGET_TRIPLET={{VCPKG_TRIPLET}} `
cmake -B $BUILD_DIR $CMAKE_ARGS -S ${{github.workspace}}
else
cmake -B $BUILD_DIR $CMAKE_ARGS
fi
shell: bash
# ---------------------------------------------------------------------- - name: Build
# CMake Build run: cmake --build ${{github.workspace}}/build --config Release
# ----------------------------------------------------------------------
- name: Build Targets - name: Upload Windows Artifact
run: cmake --build ${{github.workspace}}/build --config ${{ matrix.build_config }} uses: actions/upload-artifact@v4
with:
name: build-artifact-windows
path: ${{github.workspace}}/build/ncmdump