Skip to content

Commit

Permalink
fix(deploy): use javascript semantic-release package for deployment
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AntoineDao committed Mar 20, 2019
1 parent 3beb29b commit 3361688
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 55 deletions.
10 changes: 10 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -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}"
}]
]
}
43 changes: 21 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
- 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/
26 changes: 26 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -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
40 changes: 30 additions & 10 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion ladybug/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[semantic_release]
version_variable = ladybug/__init__.py:__version__

[bdist_wheel]
universal = 1

Expand Down
18 changes: 3 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
],
Expand Down

0 comments on commit 3361688

Please sign in to comment.