From e48d402e216e13ce11e49e773d82455ca0aeacf8 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sat, 12 Feb 2022 02:44:45 +0100 Subject: [PATCH] Improve version bumping script --- cmake/bump_version.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/bump_version.cmake b/cmake/bump_version.cmake index ba6465e..e62ef73 100644 --- a/cmake/bump_version.cmake +++ b/cmake/bump_version.cmake @@ -12,6 +12,14 @@ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/cmkr.cmake") message(FATAL_ERROR "Cannot find cmkr.cmake") endif() +# Validate branch +find_package(Git REQUIRED) +execute_process(COMMAND "${GIT_EXECUTABLE}" branch --show-current OUTPUT_VARIABLE GIT_BRANCH) +string(STRIP "${GIT_BRANCH}" GIT_BRANCH) +if(NOT GIT_BRANCH STREQUAL "main") + message(FATAL_ERROR "You need to be on the main branch, you are on: ${GIT_BRANCH}") +endif() + file(READ "${CMAKE_SOURCE_DIR}/cmake.toml" CMAKE_TOML) string(FIND "${CMAKE_TOML}" "[project]" PROJECT_INDEX) string(SUBSTRING "${CMAKE_TOML}" ${PROJECT_INDEX} -1 CMAKE_TOML_PROJECT)