Skip to content

Commit

Permalink
Merge pull request #849 from openziti/more-flexible-versions
Browse files Browse the repository at this point in the history
More flexible versions
  • Loading branch information
ekoby authored Jun 9, 2024
2 parents afe442f + 1971efc commit 3da1346
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: CI build

on:
pull_request:
branches: [ main ]
branches:
- main
- release-*
workflow_dispatch:
workflow_call:

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- release-1.x

jobs:
update_release_draft:
Expand Down
23 changes: 20 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if(NOT GIT_VERSION AND GIT_FOUND)
message("Found Git executable \"${GIT_EXECUTABLE}\".")
# Generate a git-describe version string from Git repository tags
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=-local --match "v*"
COMMAND ${GIT_EXECUTABLE} describe --long --tags
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
OUTPUT_VARIABLE GIT_VERSION
RESULT_VARIABLE GIT_ERROR_CODE
Expand All @@ -42,7 +42,14 @@ if(NOT GIT_VERSION)
set(PROJECT_SEMVER "${DUMMY_SEMVER}")
message(WARNING "GIT_VERSION not set. Using dummy PROJECT_SEMVER: \"${PROJECT_SEMVER}\", GIT_VERSION: \"${GIT_VERSION}\".")
else()
string(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" PROJECT_SEMVER "${GIT_VERSION}")
# tag-tweak-slug
string(REGEX REPLACE "(.*)-([0-9]+)-(.*)" "\\1" PROJECT_TAG "${GIT_VERSION}")
string(REGEX REPLACE "(.*)-([0-9]+)-(.*)" "\\2" PROJECT_TWEAK "${GIT_VERSION}")
string(REGEX REPLACE "(.*)-([0-9]+)-(.*)" "\\3" PROJECT_SLUG "${GIT_VERSION}")

# extract semver from pre-release tags like 2.0.0-alpha
string(REGEX MATCH "([0-9]+.[0-9]+.[0-9]+)" PROJECT_SEMVER ${PROJECT_TAG})

if(NOT PROJECT_SEMVER)
set(PROJECT_SEMVER "${DUMMY_SEMVER}")
message(WARNING "SEMVER could not be parsed from GIT_VERSION: ${GIT_VERSION}. Setting to PROJECT_SEMVER: ${PROJECT_SEMVER}")
Expand All @@ -64,10 +71,20 @@ if((NOT DISABLE_SEMVER_VERIFICATION) AND PROJECT_SEMVER VERSION_EQUAL "${DUMMY_S
message(FATAL_ERROR "SEMVER Verification failed. A valid SEMVER is required for correct package version composition. To override, set DISABLE_SEMVER_VERIFICATION=ON.")
endif()

unset(GIT_VERSION CACHE)
if (PROJECT_TWEAK STREQUAL "0")
set(GIT_VERSION ${PROJECT_TAG})
else ()
set(GIT_VERSION "${PROJECT_TAG}.${PROJECT_TWEAK}")
endif ()

project(ziti-tunnel-sdk-c
VERSION "${PROJECT_SEMVER}"
DESCRIPTION "OpenZiti tunneler SDK"
HOMEPAGE_URL "https://github.com/openziti/ziti-tunneler-sdk-c"
LANGUAGES C CXX)

set(PROJECT_VERSION ${GIT_VERSION})

if(NOT BUILD_DIST_PACKAGES)
include(CPack)
set(CPACK_PACKAGE_VENDOR "NetFoundry")
Expand Down

0 comments on commit 3da1346

Please sign in to comment.