Skip to content

Commit a537f00

Browse files
authored
Merge pull request VUnit#508 from 1138-4EB/rework-release
Rework release procedure
2 parents 82f5d55 + ba0e606 commit a537f00

File tree

4 files changed

+127
-120
lines changed

4 files changed

+127
-120
lines changed

.travis.yml

+15-34
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ script:
99

1010
stages:
1111
- test
12-
- name: deploy
13-
if: repo = VUnit/vunit
12+
- deploy
1413

1514
matrix:
1615
include:
16+
- env: BUILD_NAME=py27-lint
17+
python: '2.7'
18+
- env: BUILD_NAME=py36-lint
19+
python: '3.6'
20+
1721
- env: BUILD_NAME=py27-unit
1822
python: '2.7'
1923
- env: BUILD_NAME=py34-unit
@@ -22,18 +26,6 @@ matrix:
2226
python: '3.5'
2327
- env: BUILD_NAME=py36-unit
2428
python: '3.6'
25-
- env: BUILD_NAME=py36-unit
26-
python: '3.6'
27-
28-
- env: BUILD_NAME=py27-lint
29-
python: '2.7'
30-
- env: BUILD_NAME=py36-lint
31-
python: '3.6'
32-
33-
- env: BUILD_NAME=py27-docs
34-
python: '2.7'
35-
- env: BUILD_NAME=py36-docs
36-
python: '3.6'
3729

3830
# Python 2.7 with ghdl mcode
3931
- env: BUILD_NAME=py27-acceptance-ghdl
@@ -73,16 +65,14 @@ matrix:
7365
- cd ../../
7466
- export PATH=$PATH:install-ghdl-llvm/bin/
7567

76-
# Python 3.6 with ghdl llvm
7768
- <<: *py36
7869
env: BUILD_NAME=py36-vcomponents-ghdl
7970

80-
# Deploy to GitHub pages
81-
- stage: deploy
71+
- env: BUILD_NAME=py27-docs
72+
python: '2.7'
73+
- env: BUILD_NAME=py36-docs
8274
python: '3.6'
83-
script:
84-
- tox -e py36-docs
85-
- touch .tox/py36-docs/tmp/docsbuild/.nojekyll
75+
after_script: touch .tox/py36-docs/tmp/docsbuild/.nojekyll
8676
deploy:
8777
provider: pages
8878
repo: VUnit/VUnit.github.io
@@ -92,18 +82,16 @@ matrix:
9282
github_token: $GITHUB_PAGES_TOKEN
9383
skip_cleanup: true
9484
on:
85+
repo: VUnit/vunit
9586
branch: master
87+
tags: true
9688

9789
# Deploy to PyPI whenever the package version has changed
9890
# When a package version has not changed a new upload will not be triggered
9991
- stage: deploy
10092
python: '3.6'
101-
script:
102-
- sed -i "s/PRE_RELEASE = True/PRE_RELEASE = False/" vunit/about.py
103-
- python tools/is_new_release.py release_name is_new_release
104-
- export IS_NEW_RELEASE=`cat is_new_release`
105-
- export RELEASE_NAME=`cat release_name`
106-
93+
if: tag IS present
94+
script: python tools/new_release.py 'check'
10795
deploy:
10896
provider: pypi
10997
distributions: sdist
@@ -112,12 +100,5 @@ matrix:
112100
user: $PYPI_USER
113101
password: $PYPI_PASSWORD
114102
on:
103+
repo: VUnit/vunit
115104
branch: master
116-
condition: $IS_NEW_RELEASE = True
117-
118-
# Create release tag after successful deployment
119-
after_deploy:
120-
- git config --global user.email "[email protected]"
121-
- git config --global user.name "Travis CI"
122-
- git tag "v${RELEASE_NAME}" -a -m "Generated tag from TravisCI for release ${RELEASE_NAME}"
123-
- git push -q https://[email protected]/VUnit/vunit/ --tags >/dev/null 2>&1

docs/contributing.rst

+15-8
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,20 @@ Making releases
187187
~~~~~~~~~~~~~~~
188188

189189
Releases are automatically made by Travic CI on any ``master`` commit
190-
that has a new version set in ``vunit/about.py`` together with a
191-
corresponding release note in ``docs/release_notes/X.Y.Z.rst``. The
192-
release note files in ``docs/release_notes/`` are used to
193-
automatically generate the :ref:`release notes <release_notes>`.
190+
which is tagged.
194191

195-
Travic CI makes a release by uploading a new package to PyPI and
196-
setting a release tag named ``vX.Y.Z`` in Git.
192+
In order to tag a commit:
197193

198-
A new release will not be made if the the ``X.Y.Z`` release is already
199-
on PyPI or the repo tag is already set.
194+
- Set a new version in ``vunit/about.py``.
195+
- Add a corresponding release note in ``docs/release_notes/X.Y.Z.rst``. The
196+
release note files in ``docs/release_notes/`` are used to
197+
automatically generate the :ref:`release notes <release_notes>`.
198+
- Execute ``python tools/new_release.py``.
199+
- Push the new version/tag: ``git push vX.Y.Z``.
200+
201+
Travic CI makes a release by uploading a new package to PyPI when a tag
202+
named ``vX.Y.Z`` is found in Git. A new release will not be made if:
203+
204+
- The ``X.Y.Z`` release is already on PyPI.
205+
- The version ends with ``rc0``.
206+
- The repo tag does not exist.

tools/is_new_release.py

-78
This file was deleted.

tools/new_release.py

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
# You can obtain one at http://mozilla.org/MPL/2.0/.
4+
#
5+
# Copyright (c) 2014-2019, Lars Asplund [email protected]
6+
7+
"""
8+
Detects when a new release shall be made
9+
"""
10+
11+
from __future__ import print_function
12+
13+
import json
14+
from urllib.request import urlopen # pylint: disable=no-name-in-module, import-error
15+
import sys
16+
from os.path import dirname, join, exists
17+
from subprocess import check_output
18+
19+
20+
def get_local_version():
21+
"""
22+
Return the local python package version and check if corresponding release
23+
notes exist
24+
"""
25+
ver = check_output([
26+
sys.executable,
27+
join(dirname(__file__), "..", "setup.py"),
28+
"--version"
29+
]).decode().strip()
30+
31+
release_note = join(dirname(__file__), "..", "docs", "release_notes", ver + ".rst")
32+
if not exists(release_note):
33+
print("Not releasing version %s since release note %s does not exist" % (ver, release_note))
34+
exit(1)
35+
36+
return ver
37+
38+
39+
def check_tag(ver):
40+
return "v" + ver in set(check_output(["git", "tag", "--list"]).decode().splitlines())
41+
42+
43+
def tag_release(ver):
44+
"""
45+
Detects and tags a new release
46+
"""
47+
if check_tag(ver):
48+
print("Not tagging release version %s since tag v%s already exists"
49+
% (ver, ver))
50+
exit(1)
51+
52+
print("Tagging new release version: %s" % ver)
53+
54+
check_output([
55+
'git',
56+
'tag',
57+
'"v' + ver + '" -a -m "Generated tag from TravisCI for release ' + ver + '"'
58+
])
59+
60+
61+
def check_release(ver):
62+
"""
63+
Detects and releases a new tag
64+
"""
65+
if not check_tag(ver):
66+
print("Not releasing version %s since tag v%s does not exist"
67+
% (ver, ver))
68+
exit(1)
69+
70+
if ver.endswith("rc0"):
71+
print("Not releasing version %s since it ends with rc0" % ver)
72+
exit(1)
73+
74+
with urlopen('https://pypi.python.org/pypi/vunit_hdl/json') as fptr:
75+
info = json.load(fptr)
76+
77+
if ver in info["releases"].keys():
78+
print("Version %s has already been released" % ver)
79+
exit(1)
80+
81+
check_output([
82+
'sed',
83+
'-i',
84+
'"s/PRE_RELEASE = True/PRE_RELEASE = False/"',
85+
'vunit/about.py'
86+
])
87+
88+
print("Releasing new version: %s" % ver)
89+
90+
91+
if __name__ == "__main__":
92+
VER = get_local_version()
93+
94+
if sys.argv[1] == 'check':
95+
check_release(VER)
96+
97+
tag_release(VER)

0 commit comments

Comments
 (0)