Add Git SHA to about screen and --version (#7372)

* Add Git SHA to about screen

* Update ChangeLog

* Fixed formatting

* Use `GIT_SHA` for Git SHA

* Add `GIT_SHA` env var

* Use env var `GIT_SHA`

* Shorten the Git SHA to 8 chars for readability

* Shorten Git SHA to 8 chars

* Increase Linux timeout (Fedora 39 is always slow at deps)

* Update ChangeLog

* Revert "Update ChangeLog"

This reverts commit ac52777763571e9512e1c9b73b5cac23658d5ed2.
This commit is contained in:
Nick Bolton
2024-07-08 11:40:22 +01:00
committed by GitHub
parent bfaea34291
commit d1abddde84
5 changed files with 26 additions and 4 deletions

View File

@ -22,6 +22,7 @@ on:
- cron: "0 5 * * *"
env:
GIT_SHA: ${{ github.sha }}
SYNERGY_VERSION: ${{ github.event.inputs.version || github.event.release.tag_name }}
SYNERGY_PRODUCT_NAME: ${{ vars.SYNERGY_PRODUCT_NAME }}
SYNERGY_PACKAGE_PREFIX: ${{ vars.SYNERGY_PACKAGE_PREFIX }}
@ -176,7 +177,7 @@ jobs:
name: linux-${{ matrix.distro.name }}
runs-on: ${{ matrix.distro.runs-on }}
container: ${{ matrix.distro.container }}
timeout-minutes: 10
timeout-minutes: 20
env:
# Prevent apt prompting for input.

View File

@ -41,6 +41,7 @@ Enhancements:
- #7364 Format all source with Clang and introduce lint workflow
- #7368 Make version check URL v1-specific and configurable
- #7369 Re-implement packaging for GitHub workflows (Linux ARM)
- #7372 Add Git SHA to about screen and --version
# 1.14.6

View File

@ -25,11 +25,18 @@ macro(configure_definitions)
configure_ninja()
configure_options()
if(NOT DEFINED VERSION_URL)
if("${VERSION_URL}" STREQUAL "")
set(VERSION_URL "https://api.symless.com/version?version=v1")
endif()
add_definitions(-DSYNERGY_VERSION_URL="${VERSION_URL}")
if(NOT "$ENV{GIT_SHA}" STREQUAL "")
# Shorten the Git SHA to 8 chars for readability
string(SUBSTRING "$ENV{GIT_SHA}" 0 8 GIT_SHA_SHORT)
message(STATUS "Short Git SHA: ${GIT_SHA_SHORT}")
add_definitions(-DGIT_SHA_SHORT="${GIT_SHA_SHORT}")
endif()
if(ENABLE_LICENSING)
message(STATUS "Licensing enabled")
add_definitions(-DSYNERGY_ENABLE_LICENSING=1)

View File

@ -25,7 +25,13 @@ AboutDialog::AboutDialog(MainWindow *parent, const AppConfig &config)
setupUi(this);
m_versionChecker.setApp(parent->appPath(config.synergycName()));
m_pLabelSynergyVersion->setText(SYNERGY_VERSION);
QString version = SYNERGY_VERSION;
#ifdef GIT_SHA_SHORT
version += " (" GIT_SHA_SHORT ")";
#endif
m_pLabelSynergyVersion->setText(version);
QString buildDateString = QString::fromLocal8Bit(__DATE__).simplified();
QDate buildDate = QLocale("en_US").toDate(buildDateString, "MMM d yyyy");

View File

@ -41,6 +41,7 @@
#endif
#include <iostream>
#include <sstream>
#include <stdio.h>
#if WINAPI_CARBON
@ -79,9 +80,15 @@ void App::version() {
char copyrightBuffer[cpight_size];
snprintf(copyrightBuffer, cpight_size, kCopyright, kBuildYear);
std::stringstream version;
version << kVersion;
#ifdef GIT_SHA_SHORT
version << " (" << GIT_SHA_SHORT << ")";
#endif
char buffer[buffer_size];
snprintf(buffer, buffer_size, "%s %s, protocol version %d.%d\n%s",
argsBase().m_pname, kVersion, kProtocolMajorVersion,
argsBase().m_pname, version.str().c_str(), kProtocolMajorVersion,
kProtocolMinorVersion, copyrightBuffer);
std::cout << buffer << std::endl;