Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More flexible versions #849

Merged
merged 3 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading