From b286e526cc98398fdad27d232cfa53746e7cf1d0 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Fri, 25 Mar 2022 13:26:44 -0600 Subject: [PATCH] Generate version at build time --- src/application.py | 1 - src/update/updater.py | 2 +- src/write_version_data.py | 7 ++++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/application.py b/src/application.py index ec53fdb..df903a7 100644 --- a/src/application.py +++ b/src/application.py @@ -13,4 +13,3 @@ bts_access_token = "fe3j2ijirvevv9" bts_url = "https://issues.manuelcortez.net" update_url = "https://files.mcvsoftware.com/music_dl/update/latest.json" version = "2020.07.23" -update_next_version = "14775226" diff --git a/src/update/updater.py b/src/update/updater.py index 46a637b..49766a3 100644 --- a/src/update/updater.py +++ b/src/update/updater.py @@ -13,7 +13,7 @@ def do_update(update_type="alpha"): if hasattr(sys, "frozen") == False: return endpoint = application.update_url - version = application.update_next_version + version = application.version try: return update.perform_update(endpoint=endpoint, current_version=version, app_name=application.name, update_type=update_type, update_available_callback=available_update_dialog, progress_callback=progress_callback, update_complete_callback=update_finished) except ConnectionError: diff --git a/src/write_version_data.py b/src/write_version_data.py index 24953b3..b95d5d0 100644 --- a/src/write_version_data.py +++ b/src/write_version_data.py @@ -1,6 +1,7 @@ #! /usr/bin/env python# -*- coding: iso-8859-1 -*- """ Write version info (taken from the last commit) to application.py. This method has been implemented this way for running the alpha channel updates. This file is not intended to be called by the user. It will be used only by the Gitlab CI runner.""" +import datetime import requests from codecs import open @@ -11,8 +12,8 @@ commit = commit_info["short_id"] print("Got new version info: {commit}".format(commit=commit,)) file = open("application.py", "r", encoding="utf-8") lines = file.readlines() -lines[-2] = 'version = "{}"\n'.format(commit_info["created_at"][:10].replace("-", ".")) -lines[-1] = 'update_next_version = "{commit}"'.format(commit=commit,) +version = datetime.datetime.now().strftime("%Y.%m.%d") +lines[-1] = 'version = "{}"\n'.format(version) file.close() file2 = open("application.py", "w", encoding="utf-8") file2.writelines(lines) @@ -22,7 +23,7 @@ print("Wrote application.py with the new version info.") print("Updating next version on installer setup...") file = open("installer.nsi", "r", encoding="utf-8") contents = file.read() -contents = contents.replace("0.7", commit_info["created_at"][:10].replace("-", ".")) +contents = contents.replace("0.7", version) file.close() file2 = open("installer.nsi", "w", encoding="utf-8") file2.write(contents)