From de8f8d56fe426b239e4bf24f393f553dd1826c5e Mon Sep 17 00:00:00 2001 From: Tom Bocklisch Date: Tue, 14 Jan 2020 23:55:20 +0100 Subject: [PATCH 1/4] check SDK version before releasing a minor --- scripts/release.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/scripts/release.py b/scripts/release.py index 23b498554a19..723460bd3d4b 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -120,6 +120,39 @@ def is_valid_version_number(v: Text) -> bool: sys.exit(1) +def get_rasa_sdk_version() -> Text: + """Find out what the referenced version of the Rasa SDK is.""" + + env_file = project_root() / "requirements.txt" + + with env_file.open() as f: + for line in f.readlines(): + if "rasa-sdk" in line: + version = line.split("=")[-1] + return version.strip() + else: + raise Exception("Failed to find Rasa SDK version in requirements.txt") + + +def validate_code_is_release_ready(version: Text) -> None: + """Make sure the code base is valid (e.g. rasa sdk is up to date).""" + + sdk = get_rasa_sdk_version() + sdk_version = (Version.coerce(sdk).major, Version.coerce(sdk).minor) + rasa_version = (Version.coerce(version).major, Version.coerce(version).minor) + + if sdk_version != rasa_version: + print() + print( + f"\033[91m There is a mismatch between the Rasa SDK version ({sdk}) " + f"and the version you want to release ({version}). Before you can " + f"release Rasa OSS, you need to release the SDK and update " + f"the dependency. \033[0m" + ) + print() + sys.exit(-1) + + def git_existing_tags() -> Set[Text]: """Return all existing tags in the local git repo.""" @@ -213,6 +246,8 @@ def main(args: argparse.Namespace) -> None: version = next_version(args) confirm_version(version) + validate_code_is_release_ready(version) + write_version_file(version) generate_changelog(version) From 807fee7e9d03b699a72546282a01c484b41c533d Mon Sep 17 00:00:00 2001 From: Tom Bocklisch Date: Wed, 15 Jan 2020 10:28:22 +0100 Subject: [PATCH 2/4] some cleanups --- README.md | 2 +- changelog/_template.jinja2 | 1 + scripts/release.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 69491adbf6e3..9ee54e4c80ba 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ Releasing a new version is quite simple, as the packages are build and distribut 5. Once your PR is merged, tag a new release (this SHOULD always happen on master or release branches), e.g. using ```bash git tag 1.2.0 -m "next release" - git push origin 1.2.0 --tags + git push origin 1.2.0 ``` travis will build this tag and push a package to [pypi](https://pypi.python.org/pypi/rasa) 6. **If this is a minor release**, a new release branch should be created pointing to the same commit as the tag to allow for future patch releases, e.g. diff --git a/changelog/_template.jinja2 b/changelog/_template.jinja2 index 8e347cc42092..ffd0b121bf98 100644 --- a/changelog/_template.jinja2 +++ b/changelog/_template.jinja2 @@ -1,3 +1,4 @@ +{# Based on https://github.com/hawkowl/towncrier/blob/master/src/towncrier/templates/default.rst #} {% for section in sections %}{% set underline = "-" %}{% if section %}{{section}}{{ underline * section|length }}{% set underline = "~" %} {% endif %}{% if sections[section] %}{% for category, val in definitions.items() if category in sections[section] %} diff --git a/scripts/release.py b/scripts/release.py index 723460bd3d4b..4b16eafa8773 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -109,7 +109,7 @@ def is_valid_version_number(v: Text) -> bool: version = questionary.text( "What is the version number you want to release " - "('major', 'minor', 'patch' or valid version number]?", + "('major', 'minor', 'patch' or valid version number)?", validate=is_valid_version_number, ).ask() @@ -150,7 +150,7 @@ def validate_code_is_release_ready(version: Text) -> None: f"the dependency. \033[0m" ) print() - sys.exit(-1) + sys.exit(1) def git_existing_tags() -> Set[Text]: From 17f102f3c583a68f45e74df5ea644b4d0f6d47e4 Mon Sep 17 00:00:00 2001 From: Tom Bocklisch Date: Fri, 17 Jan 2020 16:37:42 +0100 Subject: [PATCH 3/4] Update scripts/release.py Co-Authored-By: Federico Tedin --- scripts/release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.py b/scripts/release.py index 4b16eafa8773..349bfd7a0e1e 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -126,7 +126,7 @@ def get_rasa_sdk_version() -> Text: env_file = project_root() / "requirements.txt" with env_file.open() as f: - for line in f.readlines(): + for line in f: if "rasa-sdk" in line: version = line.split("=")[-1] return version.strip() From ba14c6ba1942e3248c254d0dd2592f0da27c6ecd Mon Sep 17 00:00:00 2001 From: Tom Bocklisch Date: Fri, 17 Jan 2020 16:37:49 +0100 Subject: [PATCH 4/4] Update scripts/release.py Co-Authored-By: Federico Tedin --- scripts/release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.py b/scripts/release.py index 349bfd7a0e1e..ea92f4477089 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -135,7 +135,7 @@ def get_rasa_sdk_version() -> Text: def validate_code_is_release_ready(version: Text) -> None: - """Make sure the code base is valid (e.g. rasa sdk is up to date).""" + """Make sure the code base is valid (e.g. Rasa SDK is up to date).""" sdk = get_rasa_sdk_version() sdk_version = (Version.coerce(sdk).major, Version.coerce(sdk).minor)