Skip to content

Commit

Permalink
Fix patch versioning to count the number of commits from last major m…
Browse files Browse the repository at this point in the history
…inor (#484)
  • Loading branch information
tony-josi-aws authored Nov 25, 2024
1 parent 0e12991 commit ffd00f6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions CMakeLists.txt.versioning
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,21 @@ endfunction()
if (GIT_VERSION AND NOT ${GIT_INFO} STREQUAL "")
message("-- Using Git to calculate AWS IoT Device Client version information...")

# Get last tag from git - this only matches tags starting with v, so we ignore non-versioning tags
execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0 --tags --match "v[0-9]*"
# Get first tag with major and minor of the latest tag.
execute_process(
COMMAND bash -c "
read LATEST_MAJOR_VERSION LATEST_MINOR_VERSION < <(git describe --abbrev=0 --tags | awk -F. '
{
gsub(/^v/, \"\", \$0)

split(\$0, parts, \".\")
LATEST_MAJOR_VERSION = parts[1]
LATEST_MINOR_VERSION = parts[2]
print LATEST_MAJOR_VERSION, LATEST_MINOR_VERSION

}')
git tag --sort=creatordate | grep -E \"^v?\${LATEST_MAJOR_VERSION}\.\${LATEST_MINOR_VERSION}(\\.\[0-9]+)?\" | head -n 1
"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE ${PROJECT_NAME}_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
Expand Down

0 comments on commit ffd00f6

Please sign in to comment.