From 3361688201358e668926b02f4dea166ec7f091d9 Mon Sep 17 00:00:00 2001 From: AntoineDao Date: Tue, 19 Mar 2019 23:45:00 +0000 Subject: [PATCH] fix(deploy): use javascript semantic-release package for deployment Using the "pure" javascript implementation of semantic-release makes it a bit more flexible to set up custom scripts to run at different stages of the semantic release process. The packages used as well as scripts to run at different stages are specified in the .releaserc.json file. In this case we use standard semantic-release and add a custom deploy script on top of the normal github release setup. The custom deploy script is the new 'deploy.sh' file which takes the new version number as an argument to deploy the package to PyPi and build the documentation. #125 build(pytest): add pytest-cov deps to dev-requirements.txt build(euclid): add euclid to dev-requirements.txt --- .releaserc.json | 10 ++++++++++ .travis.yml | 43 +++++++++++++++++++++---------------------- deploy.sh | 26 ++++++++++++++++++++++++++ dev-requirements.txt | 40 ++++++++++++++++++++++++++++++---------- docs/conf.py | 6 ++---- ladybug/__init__.py | 1 - setup.cfg | 3 --- setup.py | 18 +++--------------- 8 files changed, 92 insertions(+), 55 deletions(-) create mode 100644 .releaserc.json create mode 100644 deploy.sh diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 00000000..31ea7122 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,10 @@ +{ + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/github", + ["@semantic-release/exec", { + "publishCmd": "bash deploy.sh ${nextRelease.version}" + }] + ] +} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index fca3b19d..2da42d0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,25 +17,24 @@ after_success: jobs: include: - - stage: deploy - if: branch = master AND (NOT type IN (pull_request)) - python: "3.6" - env: TRAVIS=true - script: - - git config --global user.name "ladybugbot" - - git config --global user.email "release@ladybug.tools" - - pip install python-semantic-release - - semantic-release publish - # generate updated documentation - - pip install Sphinx sphinxcontrib-fulltoc sphinx_bootstrap_theme - - sphinx-apidoc -f -e -d 4 -o ./docs ./ladybug ./ladybug/euclid.py - - sphinx-build -b html ./docs ./docs/_build/docs - # deploy to github pages - # https://docs.travis-ci.com/user/deployment/pages/ - provider: pages - skip_cleanup: true - github-token: $GH_TOKEN - keep-history: false - on: - branch: master - local_dir: docs/_build/ \ No newline at end of file + - stage: deploy + if: branch = master AND (NOT type IN (pull_request)) + before_install: + - npm i -g npm@6.6.0 + language: node_js + node_js: + - '8' + install: + - pip install -r dev-requirements.txt + - npm install @semantic-release/exec + script: + - git config --global user.email "releases@ladybug.tools" + - git config --global user.name "ladybugbot" + - npx semantic-release + provider: pages + skip_cleanup: true + github-token: $GH_TOKEN + keep-history: false + on: + branch: master + local_dir: docs/_build/ \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 00000000..429d7506 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +deploy_to_pypi() { + echo "Building distribution" + python setup.py sdist bdist_wheel + echo "Pushing new version to PyPi" + twine upload dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD +} + +build_docs() { + echo "Building documentation files" + sphinx-apidoc -f -e -d 4 -o ./docs ./ladybug ./ladybug/euclid.py + sphinx-build -b html ./docs ./docs/_build/docs -D release=$1 -D version=$1 +} + + +if [ -n "$1" ] +then + NEXT_RELEASE_VERSION=$1 +else + echo "A release version must be supplied" + exit 1 +fi + +deploy_to_pypi +build_docs $NEXT_RELEASE_VERSION \ No newline at end of file diff --git a/dev-requirements.txt b/dev-requirements.txt index 71daeca5..8766f583 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,17 +1,37 @@ -atomicwrites==1.2.1 -attrs==18.2.0 -certifi==2018.11.29 +alabaster==0.7.12 +atomicwrites==1.3.0 +attrs==19.1.0 +Babel==2.6.0 +bleach==3.1.0 +certifi==2019.3.9 chardet==3.0.4 -coverage==4.5.2 -coveralls==1.5.1 -docopt==0.6.2 +coverage==4.5.3 +docutils==0.14 euclid3==0.1 idna==2.8 -more-itertools==5.0.0 -pluggy==0.8.0 -py==1.7.0 -pytest==4.1.0 +imagesize==1.1.0 +Jinja2==2.10 +MarkupSafe==1.1.1 +more-itertools==6.0.0 +packaging==19.0 +pkginfo==1.5.0.1 +pluggy==0.9.0 +py==1.8.0 +Pygments==2.3.1 +pyparsing==2.3.1 +pytest==4.3.1 pytest-cov==2.6.1 +pytz==2018.9 +readme-renderer==24.0 requests==2.21.0 +requests-toolbelt==0.9.1 six==1.12.0 +snowballstemmer==1.2.1 +Sphinx==1.8.5 +sphinx-bootstrap-theme==0.6.5 +sphinxcontrib-fulltoc==1.2.0 +sphinxcontrib-websupport==1.1.0 +tqdm==4.31.1 +twine==1.13.0 urllib3==1.24.1 +webencodings==0.5.1 diff --git a/docs/conf.py b/docs/conf.py index 3816b171..44bca347 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,13 +22,11 @@ copyright = '2019, Ladybug Tools' author = 'Ladybug Tools' -# The short X.Y version -import ladybug -version = ladybug.__version__ - # The full version, including alpha/beta/rc tags release = '' +# for example take major/minor +version = '' # -- General configuration --------------------------------------------------- diff --git a/ladybug/__init__.py b/ladybug/__init__.py index 1dfd38ca..b94dc5a7 100644 --- a/ladybug/__init__.py +++ b/ladybug/__init__.py @@ -7,7 +7,6 @@ import importlib import pkgutil -__version__ = '0.3.0' # find and import ladybug plugins # this is a critical step to add additional functionalities to ladybug core library. diff --git a/setup.cfg b/setup.cfg index 17aca531..ed8a958e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,3 @@ -[semantic_release] -version_variable = ladybug/__init__.py:__version__ - [bdist_wheel] universal = 1 diff --git a/setup.py b/setup.py index 28573537..199a8b70 100644 --- a/setup.py +++ b/setup.py @@ -5,29 +5,17 @@ with open("README.md", "r") as fh: long_description = fh.read() -with open('ladybug/__init__.py', 'r') as fd: - version = re.search( - r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), - re.MULTILINE - ).group(1) - -try: - from semantic_release import setup_hook - setup_hook(sys.argv) -except ImportError: - pass - setuptools.setup( name="lbt-ladybug", - version=version, + use_scm_version = True, + setup_requires=['setuptools_scm'], author="Ladybug Tools", author_email="info@ladybug.tools", description="Ladybug is a Python library to load, analyze and modify EneregyPlus Weather files (epw).", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/ladybug-tools/ladybug", - packages=setuptools.find_packages(), + packages=setuptools.find_packages(exclude=["tests"]), install_requires=[ 'euclid3==0.1' ],