Skip to content

Commit

Permalink
Include git commit hash in version string in automatic builds
Browse files Browse the repository at this point in the history
  • Loading branch information
hdk5 committed Mar 31, 2024
1 parent 34fde03 commit 13bc9d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

Expand Down
2 changes: 1 addition & 1 deletion src/taiga/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 3 additions & 1 deletion src/taiga/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <fmt/format.h>

#include "taiga/version.h"

#include "base/preprocessor.h"
Expand All @@ -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;
}
Expand Down

0 comments on commit 13bc9d4

Please sign in to comment.