From 13bc9d4e157e5eeffb62fab299d97e0f0dbd7edd Mon Sep 17 00:00:00 2001 From: hdk5 Date: Thu, 25 Nov 2021 00:48:07 +0300 Subject: [PATCH] Include git commit hash in version string in automatic builds --- .github/workflows/release.yml | 9 +++++++++ src/taiga/config.h | 2 +- src/taiga/version.cpp | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b07f425c..29d80ab5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,6 +31,15 @@ jobs: - name: Build dependencies run: deps\build.bat --machine ${{matrix.arch}} + - name: Put git commit hash in version value + run: | + ( + Get-Content -Path src\taiga\config.h + ) -Replace ( + "(?<=#define TAIGA_VERSION_BUILD 0x).*", + (git rev-parse --short HEAD) + ) | Set-Content -Path src\taiga\config.h + - name: Build Taiga run: msbuild "project\vs2022\Taiga.sln" /m /p:Configuration=Release /p:Platform=${{matrix.arch}} diff --git a/src/taiga/config.h b/src/taiga/config.h index c3b41403..ca502684 100644 --- a/src/taiga/config.h +++ b/src/taiga/config.h @@ -34,7 +34,7 @@ #define TAIGA_VERSION_MINOR 4 #define TAIGA_VERSION_PATCH 1 #define TAIGA_VERSION_PRE "" -#define TAIGA_VERSION_BUILD 0 +#define TAIGA_VERSION_BUILD 0x0 // Used in version.rc #define TAIGA_VERSION_DIGITAL \ diff --git a/src/taiga/version.cpp b/src/taiga/version.cpp index 9f512eaf..af71d53e 100644 --- a/src/taiga/version.cpp +++ b/src/taiga/version.cpp @@ -16,6 +16,8 @@ ** along with this program. If not, see . */ +#include + #include "taiga/version.h" #include "base/preprocessor.h" @@ -29,7 +31,7 @@ const semaver::Version& version() { TAIGA_VERSION_MINOR, TAIGA_VERSION_PATCH, TAIGA_VERSION_PRE, - TAIGA_VERSION_BUILD > 0 ? STRINGIZE(TAIGA_VERSION_BUILD) : "" + TAIGA_VERSION_BUILD == 0 ? "" : fmt::format("{:x}", TAIGA_VERSION_BUILD) ); return version; }