MCPcopy Create free account
hub / github.com/CloverHealth/temporal-sqlalchemy / deploy

Function deploy

deploy.py:43–128  ·  view source on GitHub ↗

Deploys the package and documentation. Proceeds in the following steps: 1. Ensures proper environment variables are set and checks that we are on Circle CI 2. Tags the repository with the new version 3. Creates a standard distribution and a wheel 4. Updates version.py to have t

(target)

Source from the content-addressed store, hash-verified

41
42
43def deploy(target):
44 """Deploys the package and documentation.
45
46 Proceeds in the following steps:
47
48 1. Ensures proper environment variables are set and checks that we are on Circle CI
49 2. Tags the repository with the new version
50 3. Creates a standard distribution and a wheel
51 4. Updates version.py to have the proper version
52 5. Commits the ChangeLog, AUTHORS, and version.py file
53 6. Pushes to PyPI
54 7. Pushes the tags and newly committed files
55
56 Raises:
57 `EnvironmentError`:
58 - Not running on CircleCI
59 - `*_PYPI_USERNAME` and/or `*_PYPI_PASSWORD` environment variables
60 are missing
61 - Attempting to deploy to production from a branch that isn't master
62 """
63 # Ensure proper environment
64 if not os.getenv(CIRCLECI_ENV_VAR): # pragma: no cover
65 raise EnvironmentError('Must be on CircleCI to run this script')
66
67 current_branch = os.getenv('CIRCLE_BRANCH')
68 if (target == 'PROD') and (current_branch != 'master'):
69 raise EnvironmentError((
70 'Refusing to deploy to production from branch {current_branch!r}. '
71 'Production deploys can only be made from master.'
72 ).format(current_branch=current_branch))
73
74 if target in ('PROD', 'TEST'):
75 pypi_username = os.getenv('{target}_PYPI_USERNAME'.format(target=target))
76 pypi_password = os.getenv('{target}_PYPI_PASSWORD'.format(target=target))
77 else:
78 raise ValueError(
79 "Deploy target must be 'PROD' or 'TEST', got {target!r}.".format(target=target))
80
81 if not (pypi_username and pypi_password): # pragma: no cover
82 raise EnvironmentError((
83 "Missing '{target}_PYPI_USERNAME' and/or '{target}_PYPI_PASSWORD' "
84 "environment variables. These are required to push to PyPI."
85 ).format(target=target))
86
87 # Twine requires these environment variables to be set. Subprocesses will
88 # inherit these when we invoke them, so no need to pass them on the command
89 # line. We want to avoid that in case something's logging each command run.
90 os.environ['TWINE_USERNAME'] = pypi_username
91 os.environ['TWINE_PASSWORD'] = pypi_password
92
93 # Set up git on circle to push to the current branch
94 _shell('git config --global user.email "oss@cloverhealth.com"')
95 _shell('git config --global user.name "Circle CI"')
96 _shell('git config push.default current')
97
98 # Obtain the version to deploy
99 ret = _shell('make version', stdout=subprocess.PIPE)
100 version = ret.stdout.decode('utf-8').strip()

Callers 1

deploy.pyFile · 0.85

Calls 2

_shellFunction · 0.85
_pypi_pushFunction · 0.85

Tested by

no test coverage detected