Skip to content

Commit

Permalink
build(actions): add build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
cheetahbyte committed Aug 5, 2024
1 parent b04e333 commit 56fbad4
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CMake Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:

strategy:
matrix:
os: [ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up CMake
uses: lukka/get-cmake@v3

- name: Install dependencies on Ubuntu
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y g++-12
- name: Install dependencies on Windows
if: runner.os == 'Windows'
run: |
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System'
choco install -y visualstudio2019buildtools
choco install -y visualstudio2019-workload-vctools
- name: Create build directory
run: mkdir build

- name: Configure with CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

- name: Build with CMake
run: cmake --build build --config Release

- name: Install
run: cmake --install build --prefix install

- name: Package with CPack
run: cpack --config build/CPackConfig.cmake
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project(git_utils)

set(CMAKE_CXX_STANDARD 26)

set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")

include(FetchContent)

FetchContent_Declare(
Expand All @@ -25,4 +27,8 @@ add_executable(git_utils src/main.cpp
src/config.cpp
src/config.h)

target_link_libraries(git_utils PRIVATE fkYAML::fkYAML)
target_link_libraries(git_utils PRIVATE fkYAML::fkYAML)

install(TARGETS git_utils DESTINATION bin)

include(CPack)
3 changes: 2 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "gitutil.h"

int main() {
std::cout << GitUtil::getVersion() << std::endl;
GitUtil util;
std::cout << util.getVersion() << std::endl;
return 0;
}

0 comments on commit 56fbad4

Please sign in to comment.