blob: 5db7a6173ccebddc1ab12b7dfc5669e628775510 [file] [log] [blame]
Alex Gaynor0e10f572014-01-06 13:17:31 -08001# Licensed under the Apache License, Version 2.0 (the "License");
2# you may not use this file except in compliance with the License.
3# You may obtain a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS,
9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10# implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13from __future__ import absolute_import, division, print_function
14
Alex Gaynor6bc3af72014-01-06 12:04:53 -080015import os
16import re
17
18import invoke
19
20
21def update_version(filename, identifier, version):
22 path = os.path.join(os.path.dirname(__file__), filename)
23 with open(path) as f:
24 contents = f.read()
25 contents = re.sub(
26 r"^{} = .*?$".format(identifier),
27 '{} = "{}"'.format(identifier, version),
28 contents
29 )
30 with open(path, "w") as f:
31 f.write(contents)
32
33
34@invoke.task
35def release(version):
36 """
37 ``version`` should be a string like '0.4' or '1.0'.
38 """
39 # This checks for changes in the repo.
40 invoke.run("git diff-index --quiet HEAD")
41
Alex Gaynor7b8ef392014-01-06 15:16:49 -080042 update_version("cryptography/__about__.py", "__version__", version)
43 update_version("docs/conf.py", "version", version)
44 update_version("docs/conf.py", "release", version)
Alex Gaynor6bc3af72014-01-06 12:04:53 -080045
46 invoke.run("git commit -am 'Bump version numbers for release.'")
Alex Gaynor6b1235a2014-01-06 15:28:59 -080047 invoke.run("git push")
Alex Gaynor6bc3af72014-01-06 12:04:53 -080048 invoke.run("git tag -s {}".format(version))
Alex Gaynor6b1235a2014-01-06 15:28:59 -080049 invoke.run("git push --tags")
Alex Gaynor6bc3af72014-01-06 12:04:53 -080050
51 invoke.run("python setup.py sdist bdist_wheel")
52 invoke.run("twine upload -s dist/cryptography-{}*".format(version))