Skip to content

Commit

Permalink
Add build package + deploy to Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
lmazuel committed Jan 12, 2017
1 parent e66e89c commit e024fb8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,15 @@ script:
- python ./azure_nosetests.py
after_success:
- bash <(curl -s https://codecov.io/bash)
before_deploy:
- python ./before_deploy.py
deploy:
provider: pypi
user: Laurent.Mazuel
password: $PYPIPASSWORD
server: https://test.pypi.org/legacy/
distributions: check # Hack, packages will be created by "before deploy" script
on:
tags: true
branch: testdeploy
python: '3.6' # Universal wheel, don't need to deploy with Py2.7
35 changes: 35 additions & 0 deletions before_deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python

#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------

import os
import sys
import re
from pathlib import Path
from build_package import create_package

travis_tag = os.environ.get('TRAVIS_TAG')
if not travis_tag:
print("TRAVIS_TAG environment variable is not present")
sys.exit()

matching = re.match(r"^(?P<name>azure[a-z\-]*) (?P<version>[.0-9]+[rc0-9]*)$", travis_tag)
if not matching:
print("TRAVIS_TAG is not '<package_name> <version>'")
sys.exit()

name, version = matching.groups()
create_package(name, '../dist')

print("Produced:\n{}".format(list(Path('./dist').glob('*'))))

pattern = "*{}*".format(version)
packages = list(Path('./dist').glob(pattern))
if not packages:
sys.exit("Package version does not match tag {}, abort".format(version))
else:
print("Package created as expected")
6 changes: 3 additions & 3 deletions build_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
DEFAULT_DEST_FOLDER = "./dist"

def create_package(name, dest_folder=DEFAULT_DEST_FOLDER):
os.chdir(name) # Will raise if not exists
check_call(['python', 'setup.py', 'bdist_wheel', '-d', dest_folder])
check_call(['python', 'setup.py', "sdist", "--format", "zip", '-d', dest_folder])
absdirpath = os.path.abspath(name)
check_call(['python', 'setup.py', 'bdist_wheel', '-d', dest_folder], cwd=absdirpath)
check_call(['python', 'setup.py', "sdist", "--format", "zip", '-d', dest_folder], cwd=absdirpath)

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Build Azure package.')
Expand Down

0 comments on commit e024fb8

Please sign in to comment.