Skip to content

Commit

Permalink
Add endpoint to show app version info via API and GUI.
Browse files Browse the repository at this point in the history
Update the CI/CD pipeline to automatically place version information
in the version.yml file prior to packaging the app. That way the
app knows what version it is based on the tag.
  • Loading branch information
jreed1701 committed Aug 27, 2024
1 parent 02359e8 commit 347875f
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 7 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/main-branch-after-merge-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ jobs:
coverage run -m pytest
coverage report --fail-under 40
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Update Package Version
run: |
python version.py -v ${{ steps.tag_version.outputs.new_tag }}
- name: Run PyInstaller
run: |
python package.py
Expand All @@ -56,12 +66,6 @@ jobs:
run: |
python checksum.py
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
Expand Down
14 changes: 13 additions & 1 deletion application/api/v1/blueprints/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import threading
import sqlalchemy.exc as exc
import yaml

from flask import Blueprint, jsonify, request
from flask import Blueprint, jsonify, request, current_app
from flask.views import MethodView

from application.api.controllers import app as app_controller
Expand All @@ -14,6 +16,16 @@
app = Blueprint("app", __name__, url_prefix="/v1")


@app.route("/version", methods=["GET"])
def get_version():
version_file = os.path.join(current_app.static_folder, "version.yml")

with open(version_file, "r") as file:
version_data = yaml.safe_load(file)

return jsonify(version_data)


@app.route("/thread/status/<int:ident>", methods=["GET"])
def is_thread_alive(ident: int):
logger.debug("Checking thread!")
Expand Down
36 changes: 36 additions & 0 deletions application/gui/widgets/about_widget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from PyQt5.QtWidgets import (
QWidget,
QLabel,
QVBoxLayout,
)

from application.common.decorators import timeit
from operator_client import Operator


class AboutWidget(QWidget):
@timeit
def __init__(
self,
client: Operator,
parent: QWidget = None,
):
super(QWidget, self).__init__(parent)
self._layout = QVBoxLayout()
self._client = client
self._initialized = False

self.init_ui()

def init_ui(self):
v_layout = QVBoxLayout()

version = self._client.app.get_app_version()
q_label = QLabel(f"Software Version: {version}")
v_layout.addWidget(q_label)

self._layout.addLayout(v_layout)

self.setFocus()
self.setLayout(self._layout)
self.show()
9 changes: 9 additions & 0 deletions application/gui/widgets/settings_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from application.common import constants, logger
from application.common.decorators import timeit
from application.gui.globals import GuiGlobals
from application.gui.widgets.about_widget import AboutWidget
from application.gui.widgets.file_select_widget import FileSelectWidget
from application.gui.widgets.nginx_widget import NginxWidget
from application.gui.widgets.tokens_widget import TokensWidget
Expand All @@ -27,6 +28,8 @@ def __init__(self, client: Operator, globals: GuiGlobals, parent: QWidget = None
self._globals = globals
self._initialized = False

self._about_widget = AboutWidget(self._client, self)

self._token_widget = TokensWidget(
self._client,
self._globals._global_clipboard,
Expand Down Expand Up @@ -65,6 +68,7 @@ def init_ui(self):
self.tab1 = QWidget()
self.tab2 = QWidget()
self.tab3 = QWidget()
self.tab4 = QWidget()

tab1_layout = QVBoxLayout()
tab1_layout.addLayout(self._create_steam_path_setting(steam_install_dir))
Expand All @@ -85,9 +89,14 @@ def init_ui(self):
tab3_layout.addWidget(self._nginx_widget)
self.tab3.setLayout(tab3_layout)

tab4_layout = QVBoxLayout()
tab4_layout.addWidget(self._about_widget)
self.tab4.setLayout(tab4_layout)

self.tabs.addTab(self.tab1, "Paths")
self.tabs.addTab(self.tab2, "Tokens")
self.tabs.addTab(self.tab3, "Nginx")
self.tabs.addTab(self.tab4, "About")

self._layout.addWidget(self.tabs)

Expand Down
1 change: 1 addition & 0 deletions application/static/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version: 0.0.0
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pyjwt
pyopenssl
pyqt5
python-dotenv
pyyaml
requests
validators==0.20.0
vdf==3.4
Expand Down
28 changes: 28 additions & 0 deletions version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import argparse
import os
import yaml


def set_version(new_version: str):
version_file = os.path.join("application", "static", "version.yml")

with open(version_file, "r") as ver_file:
version_data = yaml.safe_load(ver_file)
ver_file.close()

with open(version_file, "w") as ver_file:
version_data["version"] = new_version
yaml.dump(version_data, ver_file)
ver_file.close()


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--version", type=str, help="New Version String")
args = parser.parse_args()

if args.version is None:
print("Error: Missing Argument! Try again.")
else:
print(f"Version String: {args.version}")
set_version(args.version)

0 comments on commit 347875f

Please sign in to comment.