Skip to content

Commit

Permalink
alternative approach using version.txt instead of directly calling git
Browse files Browse the repository at this point in the history
  • Loading branch information
Taepper committed Jan 22, 2025
1 parent 405d26a commit e825ff6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Update version.txt to contain the precise version of this commit
run: |
git describe --tags --match 'v*' > version.txt
- name: Determine HEAD_SHA
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
Expand Down
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ find_package(re2 REQUIRED)
# ---------------------------------------------------------------------------

execute_process(
COMMAND git describe --tags --match "v*"
OUTPUT_VARIABLE GIT_VERSION
COMMAND cat version.txt
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE GIT_AVAILABLE
RESULT_VARIABLE VERSION_AVAILABLE
)
if (GIT_AVAILABLE EQUAL 0)
message(STATUS "Git version: ${GIT_VERSION}")
add_compile_definitions(SILO_GIT_VERSION="${GIT_VERSION}")
if (VERSION_AVAILABLE EQUAL 0)
message(STATUS "Version: ${VERSION}")
add_compile_definitions(SILO_VERSION="${VERSION}")
else ()
message(STATUS "git is not available for identifying the current version")
message(STATUS "No version.txt available for setting the version")
endif()

# ---------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions include/silo/common/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace silo {

#ifdef SILO_GIT_VERSION
constexpr std::string_view GIT_VERSION = SILO_GIT_VERSION;
#ifdef SILO_VERSION
constexpr std::string_view VERSION = SILO_VERSION;
#else
constexpr std::string_view GIT_VERSION = "unknown";
constexpr std::string_view VERSION = "unknown";
#endif

} // namespace silo
2 changes: 1 addition & 1 deletion src/silo/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ DatabaseInfo Database::getDatabaseInfo() const {
);

return DatabaseInfo{
.git_version = silo::GIT_VERSION,
.git_version = silo::VERSION,
.sequence_count = sequence_count,
.total_size = total_size,
.n_bitmaps_size = nucleotide_symbol_n_bitmaps_size,
Expand Down

0 comments on commit e825ff6

Please sign in to comment.