Verified Commit 0a39a2e6 authored by Lars Bilke's avatar Lars Bilke

[ci] Added meta job to gather git info.

Is used by the Doxygen job to populate the git version info.
parent 137491c1
......@@ -49,3 +49,4 @@ include:
- local: '/scripts/ci/jobs/clang-sanitizer.yml'
- local: '/scripts/ci/jobs/clang-tidy.yml'
- local: '/scripts/ci/jobs/code-quality.yml'
- local: '/scripts/ci/jobs/meta.yml'
......@@ -2,13 +2,12 @@ build docs:
stage: build
image:
name: $CONTAINER_GCC_IMAGE
extends:
- .defaults
needs:
- job: meta
before_script:
# HACK to easier linking to the generated pages
- echo '<meta http-equiv="REFRESH" content="0;URL=build/docs/index.html">' >> Doxygen.html
- git fetch --tags
- mkdir -p build
- cd build
......
meta:
stage: .pre
tags:
- envinf1-shell
script:
- git fetch --depth 500
- echo "OGS_VERSION=${CI_COMMIT_TAG:-`git describe --tags --long --dirty --always`}" >> build.env
- cat build.env
artifacts:
reports:
dotenv: build.env
......@@ -33,46 +33,51 @@ if(NOT IS_GIT_REPO)
return()
endif()
# Get version info from Git, implementation based on
# https://github.com/tomtom-international/cpp-dependencies
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --long --dirty --always
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE DESCRIBE_RESULT
OUTPUT_VARIABLE DESCRIBE_STDOUT
)
if(DESCRIBE_RESULT EQUAL 0)
string(STRIP "${DESCRIBE_STDOUT}" DESCRIBE_STDOUT)
message(STATUS "Git reported this project's version as '${DESCRIBE_STDOUT}'")
if(DESCRIBE_STDOUT MATCHES "^(.*)-(dirty)$")
set(DESCRIBE_DIRTY "${CMAKE_MATCH_2}")
set(DESCRIBE_STDOUT "${CMAKE_MATCH_1}")
endif()
if(DESCRIBE_STDOUT MATCHES "^([0-9a-f]+)$")
set(DESCRIBE_COMMIT_NAME "${CMAKE_MATCH_1}")
set(DESCRIBE_STDOUT "")
elseif(DESCRIBE_STDOUT MATCHES "^(.*)-g([0-9a-f]+)$")
set(DESCRIBE_COMMIT_NAME "g${CMAKE_MATCH_2}")
set(DESCRIBE_STDOUT "${CMAKE_MATCH_1}")
endif()
if(DESCRIBE_STDOUT MATCHES "^(.*)-([0-9]+)$")
set(DESCRIBE_COMMIT_COUNT "${CMAKE_MATCH_2}")
set(DESCRIBE_TAG "${CMAKE_MATCH_1}")
set(DESCRIBE_STDOUT "")
endif()
if(DEFINED ENV{OGS_VERSION})
set(OGS_VERSION $ENV{OGS_VERSION})
message(STATUS "OGS VERSION: ${OGS_VERSION} (set via environment)")
else()
# Get version info from Git, implementation based on
# https://github.com/tomtom-international/cpp-dependencies
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --long --dirty --always
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE DESCRIBE_RESULT
OUTPUT_VARIABLE DESCRIBE_STDOUT
)
if(DESCRIBE_RESULT EQUAL 0)
string(STRIP "${DESCRIBE_STDOUT}" DESCRIBE_STDOUT)
message(STATUS "Git reported this project's version as '${DESCRIBE_STDOUT}'")
if(DESCRIBE_STDOUT MATCHES "^(.*)-(dirty)$")
set(DESCRIBE_DIRTY "${CMAKE_MATCH_2}")
set(DESCRIBE_STDOUT "${CMAKE_MATCH_1}")
endif()
if(DESCRIBE_STDOUT MATCHES "^([0-9a-f]+)$")
set(DESCRIBE_COMMIT_NAME "${CMAKE_MATCH_1}")
set(DESCRIBE_STDOUT "")
elseif(DESCRIBE_STDOUT MATCHES "^(.*)-g([0-9a-f]+)$")
set(DESCRIBE_COMMIT_NAME "g${CMAKE_MATCH_2}")
set(DESCRIBE_STDOUT "${CMAKE_MATCH_1}")
endif()
if(DESCRIBE_STDOUT MATCHES "^(.*)-([0-9]+)$")
set(DESCRIBE_COMMIT_COUNT "${CMAKE_MATCH_2}")
set(DESCRIBE_TAG "${CMAKE_MATCH_1}")
set(DESCRIBE_STDOUT "")
endif()
set(OGS_VERSION ${DESCRIBE_TAG})
if(DESCRIBE_COMMIT_COUNT GREATER 0)
set(OGS_VERSION "${OGS_VERSION}-${DESCRIBE_COMMIT_COUNT}-${DESCRIBE_COMMIT_NAME}")
endif()
set(OGS_VERSION ${DESCRIBE_TAG})
if(DESCRIBE_COMMIT_COUNT GREATER 0)
set(OGS_VERSION "${OGS_VERSION}-${DESCRIBE_COMMIT_COUNT}-${DESCRIBE_COMMIT_NAME}")
endif()
if(DESCRIBE_DIRTY)
string(TIMESTAMP DESCRIBE_DIRTY_TIMESTAMP "%Y%m%d%H%M%S" UTC)
set(OGS_VERSION "${OGS_VERSION}.dirty.${DESCRIBE_DIRTY_TIMESTAMP}")
if(DESCRIBE_DIRTY)
string(TIMESTAMP DESCRIBE_DIRTY_TIMESTAMP "%Y%m%d%H%M%S" UTC)
set(OGS_VERSION "${OGS_VERSION}.dirty.${DESCRIBE_DIRTY_TIMESTAMP}")
endif()
message(STATUS "OGS VERSION: ${OGS_VERSION}")
else()
message(WARNING "Git repository contains no tags! Please run: git fetch --tags")
endif()
message(STATUS "OGS VERSION: ${OGS_VERSION}")
else()
message(WARNING "Git repository contains no tags! Please run: git fetch --tags")
endif()
# Get git commit
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment