forked from VUnit/vunit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request VUnit#508 from 1138-4EB/rework-release
Rework release procedure
- Loading branch information
Showing
4 changed files
with
127 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |