This commit is contained in:
47
main.py
47
main.py
@@ -12,10 +12,14 @@ from package import Package
|
||||
## Autopkg Apps
|
||||
apps = {
|
||||
"bitcoinknots": {
|
||||
"name": "Bitcoin Knots",
|
||||
"url": "https://api.github.com/repos/bitcoinknots/bitcoin/releases/latest",
|
||||
"versioningScheme": r"^v(\d+)\.(\d+)\.(\d+)$"
|
||||
"versioningScheme": r"^v(\d+)\.(\d+)\.knots(\d{8})$"
|
||||
},
|
||||
"electrs": {"url": "https://api.github.com/repos/romanz/electrs/releases/latest"}
|
||||
"electrs": {
|
||||
"name": "electrs",
|
||||
"url": "https://api.github.com/repos/romanz/electrs/releases/latest"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,12 +51,6 @@ class Autopkg:
|
||||
|
||||
self.data.read(self.datafile)
|
||||
|
||||
## Setup file if not present
|
||||
if "Versions" not in self.data:
|
||||
self.data.add_section("Versions")
|
||||
|
||||
self.write_data()
|
||||
|
||||
|
||||
# Write datafile changes
|
||||
def write_data(self):
|
||||
@@ -62,11 +60,23 @@ class Autopkg:
|
||||
|
||||
# Main Application
|
||||
def main(self):
|
||||
# Handle apps (get versions)
|
||||
# Handle apps
|
||||
for app, info in apps.items():
|
||||
ini_version = self.data.get("Versions", app, fallback=None) # Version previously packaged from data.ini
|
||||
# Setup INI file
|
||||
if f"tags.{app}" not in self.data:
|
||||
self.data.add_section(f"tags.{app}")
|
||||
|
||||
response = requests.get(info["url"]) # Fetch data from API
|
||||
self.write_data()
|
||||
|
||||
# Grab data from data file
|
||||
data_section = f"tags.{app}"
|
||||
data_tag = []
|
||||
|
||||
for i in self.data.items(conf_section):
|
||||
tag.append(i[1])
|
||||
|
||||
|
||||
response = requests.get(info["url"]) # Fetch data from Git API
|
||||
|
||||
# Parse through JSON data
|
||||
if response.status_code == 200:
|
||||
@@ -87,13 +97,24 @@ class Autopkg:
|
||||
logging.error(f"Error starting docker container for {app}")
|
||||
|
||||
|
||||
def version_is_higher(tag: str, info: dict) -> (str, None):
|
||||
def version_is_higher(tag: str, ini_tag: tuple, app_info: dict) -> (str, None):
|
||||
regular_scheme = r"^v(\d+)\.(\d+)\.(\d+)$"
|
||||
|
||||
try:
|
||||
version = re.match(info["versioningScheme"], tag)
|
||||
except:
|
||||
version = re.match(regular_scheme)
|
||||
version = re.match(regular_scheme, tag)
|
||||
|
||||
if version:
|
||||
tag_major = int(version.group(1))
|
||||
tag_minor = int(version.group(2))
|
||||
tag_patch = int(version.group(3))
|
||||
else:
|
||||
logging.warning(f"New tag for {app_info["name"]} doesn't follow versioning schemes, ignoring..")
|
||||
|
||||
return None
|
||||
|
||||
if
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user