Generate version at build time

This commit is contained in:
Manuel Cortez 2022-03-25 13:26:44 -06:00
parent a1b29005bb
commit b286e526cc
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
3 changed files with 5 additions and 5 deletions

View File

@ -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"

View File

@ -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:

View File

@ -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)