diff --git a/Jenkinsfile b/Jenkinsfile index 99fa74a..bd3e023 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ pipeline { dir('bioconda-recipes') { sh 'git pull' sh 'git pull origin update-autobigs-engine' - sh 'git pull origin update-autobigs-engine' + sh 'git pull origin update-autobigs-cli' } } } @@ -44,8 +44,15 @@ pipeline { stage("overwrite") { steps { dir('bioconda-recipes') { - sh 'checkout ' - sh 'cp autobigs-engine/* ' + sh 'git checkout -b update-autobigs-engine' + sh 'cp -r ../autobigs-engine/* recipes/autobigs-engine/.' + sh 'git commit -a -m "Automatically updated autobigs-engine bioconda recipe to $(python ../scripts/package_latest_version.py autoBIGS.engine)."' + sh 'git push origin update-autobigs-engine' + + sh 'git checkout -b update-autobigs-cli' + sh 'cp -r ../autobigs-engine/* recipes/autobigs-cli/.' + sh 'git commit -a -m "Automatically updated autobigs-cli bioconda recipe to $(python ../scripts/package_latest_version.py autoBIGS.engine)."' + sh 'git push origin update-autobigs-cli' } } } diff --git a/scripts/adapt_names.py b/scripts/adapt_names.py old mode 100644 new mode 100755 index 6103340..5d1d91c --- a/scripts/adapt_names.py +++ b/scripts/adapt_names.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import argparse from os import fdopen, path import os @@ -6,8 +8,8 @@ import shutil from sys import argv import tempfile -def main(): - original_recipe = path.abspath(argv[1]) +def update_naming_scheme(recipe_path): + original_recipe = path.abspath(recipe_path) original_meta = path.join(original_recipe, "meta.yaml") new_fd, new_file_path = tempfile.mkstemp() with fdopen(new_fd, "w") as new_file_handle: @@ -27,4 +29,4 @@ def main(): new_recipe_name) if __name__ == "__main__": - main() \ No newline at end of file + update_naming_scheme(argv[1]) \ No newline at end of file diff --git a/scripts/package_latest_version.py b/scripts/package_latest_version.py new file mode 100755 index 0000000..550dcaa --- /dev/null +++ b/scripts/package_latest_version.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +import sys +import requests +import json +try: + from packaging.version import parse +except ImportError: + from pip._vendor.packaging.version import parse + + +URL_PATTERN = 'https://pypi.python.org/pypi/{package}/json' + + +def get_version(package, url_pattern=URL_PATTERN): + """Return version of package on pypi.python.org using json.""" + req = requests.get(url_pattern.format(package=package)) + version = parse('0') + if req.status_code == requests.codes.ok: + j = json.loads(req.text.encode(req.encoding or "utf-8")) + releases = j.get('releases', []) + for release in releases: + ver = parse(release) + if not ver.is_prerelease: + version = max(version, ver) + return version + + +if __name__ == '__main__': + print(get_version(sys.argv[1]), end="") \ No newline at end of file