From 4177052fb7b2e9f5e500f2c3e2b79290689c3419 Mon Sep 17 00:00:00 2001 From: Maschell Date: Thu, 6 Oct 2022 23:12:45 +0200 Subject: [PATCH] Support using the git hash on nightlies --- .github/workflows/ci.yml | 7 +++++++ .github/workflows/pr.yml | 7 +++++++ src/main.cpp | 3 ++- src/main.h | 15 +++------------ src/version.h | 2 ++ 5 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 src/version.h diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4fe535..7a48801 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,13 @@ jobs: needs: clang-format steps: - uses: actions/checkout@v2 + - name: create version.h + run: | + git_hash=$(git rev-parse --short "$GITHUB_SHA") + cat < ./src/version.h + #pragma once + #define VERSION_EXTRA " (nightly-$git_hash)" + EOF - name: build binary run: | docker build . -t builder diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5e87cc4..befdbe3 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -26,6 +26,13 @@ jobs: needs: clang-format steps: - uses: actions/checkout@v2 + - name: create version.h + run: | + git_hash=$(git rev-parse --short "${{ github.event.pull_request.head.sha }}") + cat < ./src/version.h + #pragma once + #define VERSION_EXTRA " (nightly-$git_hash)" + EOF - name: build binary run: | docker build . -t builder diff --git a/src/main.cpp b/src/main.cpp index bcf22a8..f1e49fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,4 @@ +#include "main.h" #include "globals.h" #include "utils/TcpReceiver.h" #include "utils/logger.h" @@ -8,7 +9,7 @@ WUPS_PLUGIN_NAME("Wiiload"); WUPS_PLUGIN_DESCRIPTION("Wiiload Server"); -WUPS_PLUGIN_VERSION("0.1"); +WUPS_PLUGIN_VERSION(VERSION_FULL); WUPS_PLUGIN_AUTHOR("Maschell"); WUPS_PLUGIN_LICENSE("GPL"); diff --git a/src/main.h b/src/main.h index b92ea46..a87e236 100644 --- a/src/main.h +++ b/src/main.h @@ -1,14 +1,5 @@ #pragma once +#include "version.h" -/* Main */ -#ifdef __cplusplus -extern "C" { -#endif -#include -#include - -#ifdef __cplusplus -} -#endif - -#endif +#define VERSION "v0.1" +#define VERSION_FULL VERSION VERSION_EXTRA \ No newline at end of file diff --git a/src/version.h b/src/version.h new file mode 100644 index 0000000..66a2c7e --- /dev/null +++ b/src/version.h @@ -0,0 +1,2 @@ +#pragma once +#define VERSION_EXTRA "" \ No newline at end of file