Skip to content

Build with CMake

Build with CMake #2

Workflow file for this run

# Copyright (c) 2020-2021-2022 Luca Cappa
# Released under the term specified in file LICENSE.txt
# SPDX short identifier: MIT
#
# The peculiarity of this workflow is that assumes vcpkg is NOT stored as a submodule of this repository.
# This workflow does the following:
# - Restores vcpkg artifacts from cache.
# - Using the provided Git commit id, sets up vcpkg if needed, then run CMake with CMakePreset.json using a configuration
# that leverages the vcpkg's toolchain file. This will automatically run vcpkg to install dependencies
# described by the vcpkg.json manifest file. It will be a no-op if those are restored from cache.
# - Finally builds the sources with Ninja.
name: Build with CMake
on:
workflow_run:
workflows: ["Semantic Release"]
types:
- completed
workflow_dispatch:
inputs:
trigger_nexus_upload:
description: "Trigger Nexus upload"
required: false
default: "false"
env:
FILENAME: CrashLogger # Define the filename here to use globally
jobs:
build_cmake:
name: Build with CMake
runs-on: windows-latest
if: ${{ github.repository_owner == 'alandtse' }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Check if GitHub release tag exists
id: check_release
shell: pwsh
run: |
$RELEASE_VERSION = git describe --tags --abbrev=0 2>$null
if (-not $RELEASE_VERSION) {
Write-Host "No tags found in the repository."
echo "asset_exists=false" >> $env:GITHUB_ENV
exit 1
}
echo "release_version=$RELEASE_VERSION" >> $env:GITHUB_ENV
$response = curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" `
"https://github.com/gitapi/repos/${{ github.repository }}/releases/tags/$RELEASE_VERSION"
$json = $response | ConvertFrom-Json
if ($json -and $json.assets) {
$assets = $json.assets | Select-Object -ExpandProperty name
if ($assets -contains "${{ env.FILENAME }}_$RELEASE_VERSION.7z") {
echo "asset_exists=true" >> $env:GITHUB_ENV
} else {
echo "asset_exists=false" >> $env:GITHUB_ENV
}
} else {
Write-Host "No valid response or assets found for the release."
echo "asset_exists=false" >> $env:GITHUB_ENV
}
- name: Restore artifacts, or setup vcpkg (do not install any package)
uses: lukka/run-vcpkg@v10
id: runvcpkg
with:
vcpkgDirectory: "${{ runner.workspace }}/b/vcpkg"
vcpkgGitCommitId: ${{ env.vcpkg_commit_id }}
vcpkgJsonGlob: /vcpkg.json
- uses: lukka/get-cmake@latest
- uses: lukka/run-cmake@v10
if: ${{ needs.semantic_release.outputs.new_release == 'true' || env.asset_exists == 'false' }}
with:
cmakeListsTxtPath: "${{ github.workspace }}/CMakeLists.txt"
configurePreset: Release-MSVC
buildPreset: Release-MSVC
- name: Upload files to GitHub release
if: ${{ needs.semantic_release.outputs.new_release == 'true' || github.event.inputs.trigger_nexus_upload == 'true' }}
uses: svenstaro/upload-release-action@2.3.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: build/release-msvc/${{ env.FILENAME }}_${{ env.release_version }}.7z
tag: ${{ env.release_version }}
overwrite: true
- name: Set output for release version
run: echo "release_version=${{ env.RELEASE_VERSION }}" >> $GITHUB_ENV
- name: Set output for trigger nexus upload
run: echo "trigger_nexus_upload=${{ github.event.inputs.trigger_nexus_upload }}" >> $GITHUB_ENV
- name: Set output for new release status
id: set_release_status
run: echo "::set-output name=new_release::${{ steps.semantic.outputs.new_release_published }}"