Skip to content

[workflows]:新增更新vcpkg代码,优化vcpkg缓存的key; #89

[workflows]:新增更新vcpkg代码,优化vcpkg缓存的key;

[workflows]:新增更新vcpkg代码,优化vcpkg缓存的key; #89

Workflow file for this run

name: CMake Build
on:
# push代码时触发workflow
push:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- '.github/workflows/clean_cache.yml'
- '.github/workflows/delete_workflow.yml'
- '.github/workflows/readme.yml'
- '.github/workflows/toolchain.yml'
- '.clang*'
- '.gitignore'
- 'LICENSE'
- 'README*'
pull_request:
paths-ignore: # 下列文件的变更不触发部署,可以自行添加
- '.github/workflows/clean_cache.yml'
- '.github/workflows/delete_workflow.yml'
- '.github/workflows/readme.yml'
- '.github/workflows/toolchain.yml'
- '.clang*'
- '.gitignore'
- 'LICENSE'
- 'README*'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- macos-latest
- ubuntu-latest
build_type:
- "Release"
generators:
- "Ninja"
steps:
- name: Install dependencies on windows
if: startsWith(matrix.os, 'windows')
run: |
choco install ninja
ninja --version
cmake --version
- name: Install dependencies on macos
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
brew install ninja python-setuptools
ninja --version
cmake --version
clang --version
- name: Install dependencies on ubuntu
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install ninja-build clang
ninja --version
cmake --version
gcc --version
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install vcpkg on macos
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
sudo chmod +x install-vcpkg.sh
sudo ./install-vcpkg.sh
working-directory: ./scripts/macos
- name: Update vcpkg
shell: bash
run: |
cd "$VCPKG_INSTALLATION_ROOT"
git reset --hard
git pull --quiet
- name: Update vcpkg manifest baseline
shell: bash
run: |
vcpkg x-update-baseline
- name: Cache vcpkg
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/build/vcpkg_installed
key: ${{ matrix.os }}-vcpkg-installed-${{ runner.os }}-${{ github.sha }}
restore-keys: |
${{ matrix.os }}-vcpkg-installed-${{ runner.os }}-
${{ matrix.os }}-vcpkg-installed-
${{ matrix.os }}-
save-always: true
- name: Configure msvc for amd64
if: startsWith(matrix.os, 'windows')
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
- name: Configure windows
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
cmake \
-S . \
-B ./build \
-DCMAKE_C_COMPILER=cl \
-DCMAKE_CXX_COMPILER=cl \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-G "${{ matrix.generators }}" \
|| (cat ./build/vcpkg_installed/vcpkg/issue_body.md && exit 1)
- name: Configure macos or ubuntu
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
shell: bash
run: |
cmake \
-S . \
-B ./build \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-G "${{ matrix.generators }}" \
|| (cat ./build/vcpkg_installed/vcpkg/issue_body.md && exit 1)
- name: Build
shell: bash
run: |
cmake --build ./build --config ${{ matrix.build_type }}
- name: Test
shell: bash
run: cd build && ctest -C ${{ matrix.build_type }} --output-on-failure