Skip to content

Commit

Permalink
Merge pull request VUnit#508 from 1138-4EB/rework-release
Browse files Browse the repository at this point in the history
Rework release procedure
  • Loading branch information
kraigher authored Jun 4, 2019
2 parents 82f5d55 + ba0e606 commit a537f00
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 120 deletions.
49 changes: 15 additions & 34 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ script:

stages:
- test
- name: deploy
if: repo = VUnit/vunit
- deploy

matrix:
include:
- env: BUILD_NAME=py27-lint
python: '2.7'
- env: BUILD_NAME=py36-lint
python: '3.6'

- env: BUILD_NAME=py27-unit
python: '2.7'
- env: BUILD_NAME=py34-unit
Expand All @@ -22,18 +26,6 @@ matrix:
python: '3.5'
- env: BUILD_NAME=py36-unit
python: '3.6'
- env: BUILD_NAME=py36-unit
python: '3.6'

- env: BUILD_NAME=py27-lint
python: '2.7'
- env: BUILD_NAME=py36-lint
python: '3.6'

- env: BUILD_NAME=py27-docs
python: '2.7'
- env: BUILD_NAME=py36-docs
python: '3.6'

# Python 2.7 with ghdl mcode
- env: BUILD_NAME=py27-acceptance-ghdl
Expand Down Expand Up @@ -73,16 +65,14 @@ matrix:
- cd ../../
- export PATH=$PATH:install-ghdl-llvm/bin/

# Python 3.6 with ghdl llvm
- <<: *py36
env: BUILD_NAME=py36-vcomponents-ghdl

# Deploy to GitHub pages
- stage: deploy
- env: BUILD_NAME=py27-docs
python: '2.7'
- env: BUILD_NAME=py36-docs
python: '3.6'
script:
- tox -e py36-docs
- touch .tox/py36-docs/tmp/docsbuild/.nojekyll
after_script: touch .tox/py36-docs/tmp/docsbuild/.nojekyll
deploy:
provider: pages
repo: VUnit/VUnit.github.io
Expand All @@ -92,18 +82,16 @@ matrix:
github_token: $GITHUB_PAGES_TOKEN
skip_cleanup: true
on:
repo: VUnit/vunit
branch: master
tags: true

# Deploy to PyPI whenever the package version has changed
# When a package version has not changed a new upload will not be triggered
- stage: deploy
python: '3.6'
script:
- sed -i "s/PRE_RELEASE = True/PRE_RELEASE = False/" vunit/about.py
- python tools/is_new_release.py release_name is_new_release
- export IS_NEW_RELEASE=`cat is_new_release`
- export RELEASE_NAME=`cat release_name`

if: tag IS present
script: python tools/new_release.py 'check'
deploy:
provider: pypi
distributions: sdist
Expand All @@ -112,12 +100,5 @@ matrix:
user: $PYPI_USER
password: $PYPI_PASSWORD
on:
repo: VUnit/vunit
branch: master
condition: $IS_NEW_RELEASE = True

# Create release tag after successful deployment
after_deploy:
- git config --global user.email "[email protected]"
- git config --global user.name "Travis CI"
- git tag "v${RELEASE_NAME}" -a -m "Generated tag from TravisCI for release ${RELEASE_NAME}"
- git push -q https://[email protected]/VUnit/vunit/ --tags >/dev/null 2>&1
23 changes: 15 additions & 8 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,20 @@ Making releases
~~~~~~~~~~~~~~~

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

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

A new release will not be made if the the ``X.Y.Z`` release is already
on PyPI or the repo tag is already set.
- Set a new version in ``vunit/about.py``.
- Add a corresponding release note in ``docs/release_notes/X.Y.Z.rst``. The
release note files in ``docs/release_notes/`` are used to
automatically generate the :ref:`release notes <release_notes>`.
- Execute ``python tools/new_release.py``.
- Push the new version/tag: ``git push vX.Y.Z``.

Travic CI makes a release by uploading a new package to PyPI when a tag
named ``vX.Y.Z`` is found in Git. A new release will not be made if:

- The ``X.Y.Z`` release is already on PyPI.
- The version ends with ``rc0``.
- The repo tag does not exist.
78 changes: 0 additions & 78 deletions tools/is_new_release.py

This file was deleted.

97 changes: 97 additions & 0 deletions tools/new_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2014-2019, Lars Asplund [email protected]

"""
Detects when a new release shall be made
"""

from __future__ import print_function

import json
from urllib.request import urlopen # pylint: disable=no-name-in-module, import-error
import sys
from os.path import dirname, join, exists
from subprocess import check_output


def get_local_version():
"""
Return the local python package version and check if corresponding release
notes exist
"""
ver = check_output([
sys.executable,
join(dirname(__file__), "..", "setup.py"),
"--version"
]).decode().strip()

release_note = join(dirname(__file__), "..", "docs", "release_notes", ver + ".rst")
if not exists(release_note):
print("Not releasing version %s since release note %s does not exist" % (ver, release_note))
exit(1)

return ver


def check_tag(ver):
return "v" + ver in set(check_output(["git", "tag", "--list"]).decode().splitlines())


def tag_release(ver):
"""
Detects and tags a new release
"""
if check_tag(ver):
print("Not tagging release version %s since tag v%s already exists"
% (ver, ver))
exit(1)

print("Tagging new release version: %s" % ver)

check_output([
'git',
'tag',
'"v' + ver + '" -a -m "Generated tag from TravisCI for release ' + ver + '"'
])


def check_release(ver):
"""
Detects and releases a new tag
"""
if not check_tag(ver):
print("Not releasing version %s since tag v%s does not exist"
% (ver, ver))
exit(1)

if ver.endswith("rc0"):
print("Not releasing version %s since it ends with rc0" % ver)
exit(1)

with urlopen('https://pypi.python.org/pypi/vunit_hdl/json') as fptr:
info = json.load(fptr)

if ver in info["releases"].keys():
print("Version %s has already been released" % ver)
exit(1)

check_output([
'sed',
'-i',
'"s/PRE_RELEASE = True/PRE_RELEASE = False/"',
'vunit/about.py'
])

print("Releasing new version: %s" % ver)


if __name__ == "__main__":
VER = get_local_version()

if sys.argv[1] == 'check':
check_release(VER)

tag_release(VER)

0 comments on commit a537f00

Please sign in to comment.