feat(GODT-2655): display internal build time tag in log and GUI.

This commit is contained in:
Jakub
2023-05-26 15:07:35 +02:00
committed by Jakub Cuth
parent bfaf9765ae
commit fc06665d2b
10 changed files with 71 additions and 5 deletions

View File

@ -19,7 +19,8 @@ SRC_ICO:=bridge.ico
SRC_ICNS:=Bridge.icns
SRC_SVG:=bridge.svg
EXE_NAME:=proton-bridge
REVISION:=$(shell git rev-parse --short=10 HEAD)
REVISION:=$(shell ./utils/get_revision.sh)
TAG:=$(shell ./utils/get_revision.sh tag)
BUILD_TIME:=$(shell date +%FT%T%z)
MACOS_MIN_VERSION_ARM64=11.0
MACOS_MIN_VERSION_AMD64=10.15
@ -27,7 +28,7 @@ BUILD_ENV?=dev
BUILD_FLAGS:=-tags='${BUILD_TAGS}'
BUILD_FLAGS_LAUNCHER:=${BUILD_FLAGS}
GO_LDFLAGS:=$(addprefix -X github.com/ProtonMail/proton-bridge/v3/internal/constants., Version=${APP_VERSION} Revision=${REVISION} BuildTime=${BUILD_TIME})
GO_LDFLAGS:=$(addprefix -X github.com/ProtonMail/proton-bridge/v3/internal/constants., Version=${APP_VERSION} Revision=${REVISION} Tag=${TAG} BuildTime=${BUILD_TIME})
GO_LDFLAGS+=-X "github.com/ProtonMail/proton-bridge/v3/internal/constants.FullAppName=${APP_FULL_NAME}"
ifneq "${DSN_SENTRY}" ""
@ -158,6 +159,7 @@ ${EXE_TARGET}: check-build-essentials ${EXE_NAME}
BRIDGE_VENDOR="${APP_VENDOR}" \
BRIDGE_APP_VERSION=${APP_VERSION} \
BRIDGE_REVISION=${REVISION} \
BRIDGE_TAG=${TAG} \
BRIDGE_DSN_SENTRY=${DSN_SENTRY} \
BRIDGE_BUILD_TIME=${BUILD_TIME} \
BRIDGE_GUI_BUILD_CONFIG=Release \

View File

@ -322,6 +322,7 @@ func withLogging(c *cli.Context, crashHandler *crash.Handler, locations *locatio
WithField("appName", constants.FullAppName).
WithField("version", constants.Version).
WithField("revision", constants.Revision).
WithField("tag", constants.Tag).
WithField("build", constants.BuildTime).
WithField("runtime", runtime.GOOS).
WithField("args", os.Args).

View File

@ -33,9 +33,12 @@ var (
// Version of the build.
Version = "0.0.0"
// Revision is current hash of the build.
// Revision is build time commit hash.
Revision = ""
// Tag is build time git describe.
Tag = ""
// BuildTime stamp of the build.
BuildTime = ""

View File

@ -23,6 +23,7 @@
#define PROJECT_VENDOR "@BRIDGE_VENDOR@"
#define PROJECT_VER "@BRIDGE_APP_VERSION@"
#define PROJECT_REVISION "@BRIDGE_REVISION@"
#define PROJECT_TAG "@BRIDGE_TAG@"
#define PROJECT_BUILD_TIME "@BRIDGE_BUILD_TIME@"
#define PROJECT_DSN_SENTRY "@BRIDGE_DSN_SENTRY@"
#define PROJECT_BUILD_ENV "@BRIDGE_BUILD_ENV@"

View File

@ -286,7 +286,7 @@ QString QMLBackend::vendor() const {
//****************************************************************************************************************************************************
/// \return The value for the 'vendor' property.
/// \return The value for the 'version' property.
//****************************************************************************************************************************************************
QString QMLBackend::version() const {
HANDLE_EXCEPTION_RETURN_QSTRING(
@ -296,6 +296,15 @@ QString QMLBackend::version() const {
)
}
//****************************************************************************************************************************************************
/// \return The value for the 'tag' property.
//****************************************************************************************************************************************************
QString QMLBackend::tag() const {
HANDLE_EXCEPTION_RETURN_QSTRING(
return QString(PROJECT_TAG);
)
}
//****************************************************************************************************************************************************
/// \return The value for the 'hostname' property.

View File

@ -65,6 +65,7 @@ public: // Qt/QML properties. Note that the NOTIFY-er signal is required even fo
Q_PROPERTY(QString appname READ appname NOTIFY appnameChanged)
Q_PROPERTY(QString vendor READ vendor NOTIFY vendorChanged)
Q_PROPERTY(QString version READ version NOTIFY versionChanged)
Q_PROPERTY(QString tag READ tag NOTIFY tagChanged)
Q_PROPERTY(QString hostname READ hostname NOTIFY hostnameChanged)
Q_PROPERTY(bool isAutostartOn READ isAutostartOn NOTIFY isAutostartOnChanged)
Q_PROPERTY(bool isBetaEnabled READ isBetaEnabled NOTIFY isBetaEnabledChanged)
@ -98,6 +99,7 @@ public: // Qt/QML properties. Note that the NOTIFY-er signal is required even fo
QString appname() const; ///< Getter for the 'appname' property.
QString vendor() const; ///< Getter for the 'vendor' property.
QString version() const; ///< Getter for the 'version' property.
QString tag() const; ///< Getter for the 'tag' property.
QString hostname() const; ///< Getter for the 'hostname' property.
bool isAutostartOn() const; ///< Getter for the 'isAutostartOn' property.
bool isBetaEnabled() const; ///< Getter for the 'isBetaEnabled' property.
@ -144,6 +146,7 @@ signals: // Signal used by the Qt property system. Many of them are unused but r
void appnameChanged(QString const &appname); ///<Signal for the change of the 'appname' property.
void vendorChanged(QString const &vendor); ///<Signal for the change of the 'vendor' property.
void versionChanged(QString const &version); ///<Signal for the change of the 'version' property.
void tagChanged(QString const &tag); ///<Signal for the change of the 'tag' property.
void currentEmailClientChanged(QString const &email); ///<Signal for the change of the 'currentEmailClient' property.
void currentKeychainChanged(QString const &keychain); ///<Signal for the change of the 'currentKeychain' property.
void availableKeychainChanged(QStringList const &keychains); ///<Signal for the change of the 'availableKeychain' property.

View File

@ -76,6 +76,7 @@ function check_exit() {
Write-host "Running build for version $bridgeVersion - $buildConfig in $buildDir"
$REVISION_HASH = git rev-parse --short=10 HEAD
$bridgeTag = ($env:BRIDGE_TAG)
$bridgeDsnSentry = ($env:BRIDGE_DSN_SENTRY)
$bridgeBuidTime = ($env:BRIDGE_BUILD_TIME)
@ -93,6 +94,7 @@ git submodule update --init --recursive $vcpkgRoot
-DBRIDGE_APP_FULL_NAME="$bridgeFullName" `
-DBRIDGE_VENDOR="$bridgeVendor" `
-DBRIDGE_REVISION="$REVISION_HASH" `
-DBRIDGE_TAG="$bridgeTag" `
-DBRIDGE_APP_VERSION="$bridgeVersion" `
-DBRIDGE_BUILD_TIME="$bridgeBuidTime" `
-DBRIDGE_DSN_SENTRY="$bridgeDsnSentry" `

View File

@ -56,6 +56,7 @@ BUILD_CONFIG=${BRIDGE_GUI_BUILD_CONFIG:-Debug}
BUILD_DIR=$(echo "./cmake-build-${BUILD_CONFIG}" | tr '[:upper:]' '[:lower:]')
VCPKG_ROOT="${BRIDGE_REPO_ROOT}/extern/vcpkg"
BRIDGE_REVISION=$(git rev-parse --short=10 HEAD)
BRIDGE_TAG=${BRIDGE_TAG:-"NOTAG"}
BRIDGE_DSN_SENTRY=${BRIDGE_DSN_SENTRY}
BRIDGE_BUILD_TIME=${BRIDGE_BUILD_TIME}
BRIDGE_BUILD_ENV= ${BRIDGE_BUILD_ENV:-"dev"}
@ -97,6 +98,7 @@ cmake \
-DBRIDGE_APP_FULL_NAME="${BRIDGE_APP_FULL_NAME}" \
-DBRIDGE_VENDOR="${BRIDGE_VENDOR}" \
-DBRIDGE_REVISION="${BRIDGE_REVISION}" \
-DBRIDGE_TAG="${BRIDGE_TAG}" \
-DBRIDGE_DSN_SENTRY="${BRIDGE_DSN_SENTRY}" \
-DBRIDGE_BRIDGE_TIME="${BRIDGE_BRIDGE_TIME}" \
-DBRIDGE_BUILD_ENV="${BRIDGE_BUILD_ENV}" \

View File

@ -108,9 +108,10 @@ SettingsView {
horizontalAlignment: Text.AlignHCenter
text: qsTr("%1 v%2<br>© 2017-%3 %4<br>%5 %6<br>%7").
text: qsTr("%1 v%2 (%3)<br>© 2017-%4 %5<br>%6 %7<br>%8").
arg(Backend.appname).
arg(Backend.version).
arg(Backend.tag).
arg(Backend.buildYear()).
arg(Backend.vendor).
arg(link(Backend.licensePath, qsTr("License"))).

42
utils/get_revision.sh Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Copyright (c) 2023 Proton AG
#
# This file is part of Proton Mail Bridge.
#
# Proton Mail Bridge is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Proton Mail Bridge is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
if ! which git &> /dev/null; then
echo "NOGIT"
exit
fi
if ! git status &> /dev/null; then
echo "NOREPO"
exit
fi
if [ "$1" == "tag" ]; then
if ! git describe --tags; then
echo "NOTAG"
fi
exit
fi
if ! git rev-parse --short=10 HEAD; then
echo "NOREV"
exit
fi