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
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
runs-on: ${{ matrix.os }} - name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake libtag1-dev
- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=Release \
-S ${{github.workspace}}
- 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: env:
VCPKG_TRIPLET: x64-windows-static 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' uses: lukka/run-vcpkg@v11
run: | id: Vcpkg
sudo apt update with:
sudo apt install -y build-essential cmake libtag1-dev vcpkgJsonGlob: '**/vcpkg.json'
vcpkgTriplet: ${{ env.VCPKG_TRIPLET }}
- name: Configure CMake
run: |
$toolchainFile = "${{ steps.vcpkg.outputs.vcpkgToolchainFile }}"
cmake -B ${{github.workspace}}/build `
-DCMAKE_TOOLCHAIN_FILE=$toolchainFile `
-DVCPKG_TARGET_TRIPLET={{VCPKG_TRIPLET}} `
-S ${{github.workspace}}
- name: Install Dependencies - macOS - name: Build
if: runner.os == 'macOS' run: cmake --build ${{github.workspace}}/build --config Release
run: |
brew install git cmake taglib
- name: Install Dependencies - Windows - name: Upload Windows Artifact
uses: lukka/run-vcpkg@v11 uses: actions/upload-artifact@v4
with: with:
vcpkgJsonGlob: '**/vcpkg.json' name: build-artifact-windows
vcpkgTriplet: ${{ env.VCPKG_TRIPLET }} path: ${{github.workspace}}/build/ncmdump
# ----------------------------------------------------------------------
# CMake Configuration
# ----------------------------------------------------------------------
- name: Configure CMake
run: |
BUILD_DIR=${{ github.workspace }}/build
CMAKE_ARGS="-DCMAKE_BUILD_TYPE=${{ matrix.build_config }} -S ${{ github.workspace }}"
if [ "$RUNNER_OS" == "Windows" ]; then
CMAKE_TOOLCHAIN_FILE_PATH=$(echo ${{ steps.vcpkg.outputs.vcpkgToolchainFile }})
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE_PATH}"
cmake -B $BUILD_DIR $CMAKE_ARGS
else
cmake -B $BUILD_DIR $CMAKE_ARGS
fi
shell: bash
# ----------------------------------------------------------------------
# CMake Build
# ----------------------------------------------------------------------
- name: Build Targets
run: cmake --build ${{github.workspace}}/build --config ${{ matrix.build_config }}