From bb4881ee5d3b12cd5a54966f27f955abe219beb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Tue, 29 Oct 2024 13:44:24 +0100 Subject: [PATCH] chore: identify version numbers using a git tag - remove VERSION file - expose the `GIT_COMMIT`so that we can properly construct the web links when the user clicks the version number in Settings/About - some smaller cleanups and warning fixes Fixes #12349 --- Makefile | 3 +-- VERSION | 1 - .../main/profile_section/about/controller.nim | 7 +++++-- .../main/profile_section/about/io_interface.nim | 3 +++ .../modules/main/profile_section/about/module.nim | 3 +++ .../modules/main/profile_section/about/view.nim | 3 +++ src/app_service/service/about/service.nim | 3 +++ src/constants.nim | 4 +++- src/env_cli_vars.nim | 2 +- src/nim_status_client.nim | 2 +- storybook/pages/AboutViewPage.qml | 15 ++++++++++----- ui/app/AppLayouts/Profile/ProfileLayout.qml | 10 +++++++--- .../Profile/stores/ProfileSectionStore.qml | 6 +++++- ui/app/AppLayouts/Profile/views/AboutView.qml | 4 ++-- ui/nim-status-client.pro | 7 ++----- 15 files changed, 49 insertions(+), 24 deletions(-) delete mode 100644 VERSION diff --git a/Makefile b/Makefile index 396f4546ec..a9e2f218ba 100644 --- a/Makefile +++ b/Makefile @@ -236,8 +236,7 @@ endif NIM_PARAMS += --outdir:./bin # App version -VERSIONFILE=VERSION -DESKTOP_VERSION=`cat $(VERSIONFILE)` +DESKTOP_VERSION=`git describe --tags` STATUSGO_VERSION=`(cd vendor/status-go; git describe --tags --abbrev=0)` NIM_PARAMS += -d:DESKTOP_VERSION="$(DESKTOP_VERSION)" NIM_PARAMS += -d:STATUSGO_VERSION="$(STATUSGO_VERSION)" diff --git a/VERSION b/VERSION deleted file mode 100644 index 948f06ad77..0000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -2.30.90 diff --git a/src/app/modules/main/profile_section/about/controller.nim b/src/app/modules/main/profile_section/about/controller.nim index 090f0d5678..812dbba71a 100644 --- a/src/app/modules/main/profile_section/about/controller.nim +++ b/src/app/modules/main/profile_section/about/controller.nim @@ -27,13 +27,16 @@ proc init*(self: Controller) = self.delegate.versionFetched(args.available, args.version, args.url) proc getAppVersion*(self: Controller): string = - return self.aboutService.getAppVersion() + self.aboutService.getAppVersion() + +proc getGitCommit*(self: Controller): string = + self.aboutService.getGitCommit() proc checkForUpdates*(self: Controller) = self.aboutService.checkForUpdates() proc getNodeVersion*(self: Controller): string = - return self.aboutService.getNodeVersion() + self.aboutService.getNodeVersion() proc getStatusGoVersion*(self: Controller): string = self.aboutService.getStatusGoVersion() diff --git a/src/app/modules/main/profile_section/about/io_interface.nim b/src/app/modules/main/profile_section/about/io_interface.nim index 84f12d309e..68d9fa48ce 100644 --- a/src/app/modules/main/profile_section/about/io_interface.nim +++ b/src/app/modules/main/profile_section/about/io_interface.nim @@ -14,6 +14,9 @@ method isLoaded*(self: AccessInterface): bool {.base.} = method getAppVersion*(self: AccessInterface): string {.base.} = raise newException(ValueError, "No implementation available") +method getGitCommit*(self: AccessInterface): string {.base.} = + raise newException(ValueError, "No implementation available") + method getNodeVersion*(self: AccessInterface): string {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/profile_section/about/module.nim b/src/app/modules/main/profile_section/about/module.nim index a9ff8b5dd1..d79f7f7deb 100644 --- a/src/app/modules/main/profile_section/about/module.nim +++ b/src/app/modules/main/profile_section/about/module.nim @@ -49,6 +49,9 @@ method viewDidLoad*(self: Module) = method getAppVersion*(self: Module): string = return self.controller.getAppVersion() +method getGitCommit*(self: Module): string = + return self.controller.getGitCommit() + method getNodeVersion*(self: Module): string = return self.controller.getNodeVersion() diff --git a/src/app/modules/main/profile_section/about/view.nim b/src/app/modules/main/profile_section/about/view.nim index a9ec3561d1..6b4e1e7229 100644 --- a/src/app/modules/main/profile_section/about/view.nim +++ b/src/app/modules/main/profile_section/about/view.nim @@ -21,6 +21,9 @@ QtObject: proc getCurrentVersion*(self: View): string {.slot.} = return self.delegate.getAppVersion() + proc getGitCommit*(self: View): string {.slot.} = + return self.delegate.getGitCommit() + proc nodeVersion*(self: View): string {.slot.} = return self.delegate.getNodeVersion() diff --git a/src/app_service/service/about/service.nim b/src/app_service/service/about/service.nim index 77fcfac778..ebd245c3bb 100644 --- a/src/app_service/service/about/service.nim +++ b/src/app_service/service/about/service.nim @@ -47,6 +47,9 @@ QtObject: proc getAppVersion*(self: Service): string = return APP_VERSION + proc getGitCommit*(self: Service): string = + return GIT_COMMIT + proc getNodeVersion*(self: Service): string = try: return backend.clientVersion().result.getStr diff --git a/src/constants.nim b/src/constants.nim index 1a5f5f04ea..2ce5304643 100644 --- a/src/constants.nim +++ b/src/constants.nim @@ -1,3 +1,5 @@ +import std/strformat + include env_cli_vars ## Added a constant here cause it's easier to check the app how it behaves @@ -12,7 +14,7 @@ const STATUSGO_VERSION* {.strdefine.} = "0.0.0" # This is changed during compilation by executing git command const GIT_COMMIT* {.strdefine.} = "" -const APP_VERSION* = if defined(production): DESKTOP_VERSION else: fmt("{GIT_COMMIT}") +const APP_VERSION* = if defined(production): DESKTOP_VERSION else: fmt"{DESKTOP_VERSION}-{GIT_COMMIT}" const sep* = when defined(windows): "\\" else: "/" diff --git a/src/env_cli_vars.nim b/src/env_cli_vars.nim index 727b6e07fe..687781dbcf 100644 --- a/src/env_cli_vars.nim +++ b/src/env_cli_vars.nim @@ -1,4 +1,4 @@ -import os, sequtils, strutils, stew/shims/strformat, chronicles +import os, sequtils, strutils, chronicles import app/global/feature_flags diff --git a/src/nim_status_client.nim b/src/nim_status_client.nim index 257e4ca71b..ba185cf223 100644 --- a/src/nim_status_client.nim +++ b/src/nim_status_client.nim @@ -44,7 +44,7 @@ proc determineStatusAppIconPath(): string = if defined(production): return "/../status.png" - return "/../status-dev.png" + return "/../status-dev.png" proc prepareLogging() = # Outputs logs in the node tab diff --git a/storybook/pages/AboutViewPage.qml b/storybook/pages/AboutViewPage.qml index 2b9b7271a7..0ba1afbf49 100644 --- a/storybook/pages/AboutViewPage.qml +++ b/storybook/pages/AboutViewPage.qml @@ -30,12 +30,17 @@ SplitView { function getCurrentVersion() { logs.logEvent("store::getCurrentVersion") - return isProduction ? "0.13.2" : "45784cf0c" + return isProduction ? "0.13.2" : "0.13.2-dev" + } + + function getGitCommit() { + logs.logEvent("store::getGitCommit") + return "92b88e8a3e1d48f2c39d1db6e4d577ebbe21f7a9" } function getStatusGoVersion() { logs.logEvent("store::getStatusGoVersion") - return "0.162.9" + return "v0.162.9" } function qtRuntimeVersion() { @@ -44,10 +49,10 @@ SplitView { function getReleaseNotes() { logs.logEvent("store::getReleaseNotes") - const link = isProduction ? "https://github.com/status-im/status-desktop/releases/tag/%1" : - "https://github.com/status-im/status-desktop/commit/%1" + const link = isProduction ? "https://github.com/status-im/status-desktop/releases/tag/%1".arg(getCurrentVersion()) : + "https://github.com/status-im/status-desktop/commit/%1".arg(getGitCommit()) - openLink(link.arg(getCurrentVersion())) + openLink(link) } function openLink(url) { diff --git a/ui/app/AppLayouts/Profile/ProfileLayout.qml b/ui/app/AppLayouts/Profile/ProfileLayout.qml index 367247c315..4a513c85e6 100644 --- a/ui/app/AppLayouts/Profile/ProfileLayout.qml +++ b/ui/app/AppLayouts/Profile/ProfileLayout.qml @@ -376,6 +376,10 @@ StatusSectionLayout { return root.store.getCurrentVersion() } + function getGitCommit() { + return root.store.getGitCommit() + } + function getStatusGoVersion() { return root.store.getStatusGoVersion() } @@ -385,10 +389,10 @@ StatusSectionLayout { } function getReleaseNotes() { - const link = isProduction ? "https://github.com/status-im/status-desktop/releases/tag/%1" : - "https://github.com/status-im/status-desktop/commit/%1" + const link = isProduction ? "https://github.com/status-im/status-desktop/releases/tag/%1".arg(getCurrentVersion()) : + "https://github.com/status-im/status-desktop/commit/%1".arg(getGitCommit()) - openLink(link.arg(getCurrentVersion())) + openLink(link) } function openLink(url) { diff --git a/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml b/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml index 9c6c6e2187..c9575d7008 100644 --- a/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml +++ b/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml @@ -209,7 +209,11 @@ QtObject { } function getCurrentVersion() { - return aboutModuleInst.getCurrentVersion() + return aboutModuleInst.getCurrentVersion().replace(/^v/, '') + } + + function getGitCommit() { + return aboutModuleInst.getGitCommit() } function getStatusGoVersion() { diff --git a/ui/app/AppLayouts/Profile/views/AboutView.qml b/ui/app/AppLayouts/Profile/views/AboutView.qml index a722db5b18..75d9fcc97c 100644 --- a/ui/app/AppLayouts/Profile/views/AboutView.qml +++ b/ui/app/AppLayouts/Profile/views/AboutView.qml @@ -68,7 +68,7 @@ SettingsContentBase { font.pixelSize: 22 font.bold: true normalColor: Theme.palette.directColor1 - text: (root.store.isProduction ? "" : "git:") + root.store.getCurrentVersion() + text: root.store.getCurrentVersion() onClicked: root.store.getReleaseNotes() } @@ -84,7 +84,7 @@ SettingsContentBase { font.pixelSize: 17 font.bold: true normalColor: Theme.palette.directColor1 - text: root.store.getStatusGoVersion() + text: root.store.getStatusGoVersion().replace(/^v/, '') onClicked: root.store.openLink("https://github.com/status-im/status-go/tree/%1".arg(root.store.getStatusGoVersion())) } diff --git a/ui/nim-status-client.pro b/ui/nim-status-client.pro index 62cf398cea..0198ecf720 100644 --- a/ui/nim-status-client.pro +++ b/ui/nim-status-client.pro @@ -40,6 +40,8 @@ OTHER_FILES += $$files("$$PWD/../vendor/SortFilterProxyModel/*.h", true) OTHER_FILES += $$files("$$PWD/../vendor/nimqml/src/*.nim", true) +OTHER_FILES += $$files("$$PWD/../Makefile") + # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = $$PWD/imports \ $$PWD/StatusQ \ @@ -49,9 +51,4 @@ QML_IMPORT_PATH = $$PWD/imports \ # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = $$PWD/imports -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target - RESOURCES += resources.qrc StatusQ/src/assets.qrc StatusQ/src/statusq.qrc