mirror of
https://github.com/build-cpp/cmkr
synced 2026-06-08 13:22:55 +00:00
73 lines
2.4 KiB
YAML
73 lines
2.4 KiB
YAML
name: build
|
|
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
cmake:
|
|
# Skip building pull requests from the same repository
|
|
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [windows-2022, macos-latest, ubuntu-22.04]
|
|
env:
|
|
BUILD_TYPE: 'Release'
|
|
CMAKE_GENERATOR: 'Ninja'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Visual Studio Development Environment
|
|
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.1
|
|
|
|
- name: Tag cmkr.cmake
|
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
run: cmake -P "cmake/replace_tag.cmake"
|
|
|
|
- name: Build
|
|
run: |
|
|
cmake -B build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_UNITY_BUILD=ON
|
|
cmake --build build --config ${{ env.BUILD_TYPE }} --parallel
|
|
cmake --install build --prefix ./install --config ${{ env.BUILD_TYPE }}
|
|
|
|
- name: Check if cmkr was run
|
|
run: |
|
|
./install/bin/cmkr gen
|
|
git diff --exit-code -- . ":(exclude)cmake/cmkr.cmake"
|
|
|
|
- name: Test
|
|
run: |
|
|
cd build/tests
|
|
ctest -C ${{ env.BUILD_TYPE }} --verbose
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ github.event.repository.name }}-${{ matrix.os }}
|
|
path: install/bin/*
|
|
|
|
- name: Get lowercase OS name
|
|
id: osname
|
|
uses: ASzc/change-string-case-action@ccb130a4e483d3e86287289183704dc9bf53e77e # master 2024-04-05
|
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
with:
|
|
string: ${{ runner.os }}
|
|
|
|
- name: Compress artifacts
|
|
uses: vimtor/action-zip@1379ea20d4c5705669ba81fd626dd01b1c738f26 # v1.2
|
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
with:
|
|
files: install/bin/
|
|
dest: ${{ github.event.repository.name }}-${{ steps.osname.outputs.lowercase }}.zip
|
|
|
|
- name: Release
|
|
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2
|
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
with:
|
|
prerelease: ${{ !startsWith(github.ref, 'refs/tags/v') || contains(github.ref, '-pre') }}
|
|
files: ${{ github.event.repository.name }}-${{ steps.osname.outputs.lowercase }}.zip
|
|
generate_release_notes: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|