Skip to content

Commit

Permalink
Merge pull request #5072 from RasaHQ/check-sdk-version-on-minor-release
Browse files Browse the repository at this point in the history
check SDK version before releasing a minor
  • Loading branch information
tmbo authored Jan 17, 2020
2 parents 84d17dc + ba14c6b commit 93bc5d0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions changelog/_template.jinja2
Original file line number Diff line number Diff line change
@@ -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] %}

Expand Down
37 changes: 36 additions & 1 deletion scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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:
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."""

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 93bc5d0

Please sign in to comment.