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

Provide and parse FALCO_VERSION_PRERELEASE part #1086

Merged
merged 4 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,23 +305,23 @@ workflows:
filters:
branches:
only:
- master
- feature/version-prerelease
requires:
- "tests/integration"
- "publish/packages-dev":
context: falco
filters:
branches:
only:
- master
- feature/version-prerelease
requires:
- "rpm/sign"
- "publish/docker-dev":
context: falco
filters:
branches:
only:
- master
- feature/version-prerelease
requires:
- "publish/packages-dev"
release:
Expand Down
23 changes: 5 additions & 18 deletions cmake/modules/GetFalcoVersion.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Retrieve git ref and commit hash
include(GetGitRevisionDescription)
get_git_head_revision(FALCO_REF FALCO_HASH)

# Create the falco version variable according to git index
if(NOT FALCO_VERSION)
Expand All @@ -9,25 +8,13 @@ if(NOT FALCO_VERSION)
git_get_exact_tag(FALCO_TAG)
if(NOT FALCO_TAG)
# Obtain the closest tag
git_describe(FALCO_VERSION "--abbrev=0" "--tags") # suppress the long format
git_describe(FALCO_VERSION "--always" "--tags")
# Fallback version
if(FALCO_VERSION MATCHES "NOTFOUND$")
set(FALCO_VERSION "0.0.0")
endif()
# TODO(leodido) > Construct the prerelease part (semver 2) Construct the Build metadata part (semver 2)
if(NOT FALCO_HASH MATCHES "NOTFOUND$")
string(SUBSTRING "${FALCO_HASH}" 0 7 FALCO_VERSION_BUILD)
# Check whether there are uncommitted changes or not
git_local_changes(FALCO_CHANGES)
if(FALCO_CHANGES STREQUAL "DIRTY")
string(TOLOWER "${FALCO_CHANGES}" FALCO_CHANGES)
set(FALCO_VERSION_BUILD "${FALCO_VERSION_BUILD}.${FALCO_CHANGES}")
endif()
endif()
# Append the build metadata part (semver 2)
if(FALCO_VERSION_BUILD)
set(FALCO_VERSION "${FALCO_VERSION}+${FALCO_VERSION_BUILD}")
endif()
# Format FALCO_VERSION to be semver with prerelease and build part
string(REPLACE "-g" "+" FALCO_VERSION "${FALCO_VERSION}")
else()
# A tag has been found: use it as the Falco version
set(FALCO_VERSION "${FALCO_TAG}")
Expand All @@ -42,8 +29,8 @@ if(NOT FALCO_VERSION)
string(
REGEX
REPLACE
"^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)\\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)*).*"
"\\4"
"^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*).*"
"\\5"
FALCO_VERSION_PRERELEASE
"${FALCO_VERSION}")
if(FALCO_VERSION_PRERELEASE STREQUAL "${FALCO_VERSION}")
Expand Down