Skip to content
Snippets Groups Projects

Renovate-updates deployed to prod

Merged Tor-Einar Skog requested to merge main into release
1 file
+ 30
4
Compare changes
  • Side-by-side
  • Inline
+ 30
4
#!/usr/bin/python3
# Fetch package registry list, build models.xml structure
# with the latest version of each model
'''
Copyright (C) 2023 NIBIO
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
@author Tor-Einar Skog <tor-einar.skog@nibio.no>
'''
# Fetches the package registry list from our GitLab,
# filters only models packages,
# figures out which is the newest version of each package,
# creates Maven dependencies XML stubs
# dumps to stdout
# Example usage:
# $ ./build_models_xml.py -s > models.xml
import sys
import requests
@@ -11,9 +35,11 @@ if len(sys.argv) == 2 and sys.argv[1] == "-h":
print("""usage: build_with_models [-s]""")
exit(0)
# Use the -s option to fetch only SNAPSHOT versions
snapshot = True if len(sys.argv) == 2 and sys.argv[1] == "-s" else False
url = "https://gitlab.nibio.no/api/v4/projects/401/packages?per_page=100&order_by=version&sort=desc"
all_packages = []
response = requests.get(url)
@@ -35,6 +61,7 @@ models = {}
model_prefixes = ["no/nibio/vips/model","fi/luke/vips/model"]
# Filter models and store only the most recent version (highest alphanumeric number)
for package in all_packages:
for model_prefix in model_prefixes:
if package["name"].find(model_prefix) >=0 and ((snapshot and package["version"].find("SNAPSHOT")>=0) or (not snapshot and package["version"].find("SNAPSHOT")<0)):
@@ -53,9 +80,8 @@ for model_name, value in models.items():
ET.SubElement(dependency,"groupId").text = value["groupId"]
ET.SubElement(dependency, "artifactId").text = model_name
ET.SubElement(dependency, "version").text = value["version"]
#print("%s %s" % (model_name, value["version"]))
# Dumps the indented XML to stdout
tree = ET.ElementTree(dependencies)
ET.indent(tree, space="\t",level=0)
# Dumps the indented XML to stdout
ET.dump(tree)
Loading