diff options
| author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-06-17 09:12:58 +0200 |
|---|---|---|
| committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-06-17 13:24:47 +0200 |
| commit | 54a31ee30b6847175b2119f235ef191c95c2a504 (patch) | |
| tree | a2bea8d17d64a87e7a29cdbe995501b6c2e9c58b | |
| parent | 3f2c1e3e91077a1783cb33b8c0f11c9f70ef072c (diff) | |
| download | pylint-git-54a31ee30b6847175b2119f235ef191c95c2a504.tar.gz | |
Add tbump script for bumbing version
| -rw-r--r-- | doc/release.md | 69 | ||||
| -rw-r--r-- | requirements_test.txt | 1 | ||||
| -rw-r--r-- | script/bump_changelog.py | 80 | ||||
| -rw-r--r-- | tbump.toml | 47 |
4 files changed, 152 insertions, 45 deletions
diff --git a/doc/release.md b/doc/release.md index f3b078f42..a57e5c55f 100644 --- a/doc/release.md +++ b/doc/release.md @@ -4,43 +4,15 @@ So, you want to release the `X.Y.Z` version of pylint ? ## Process -1. Run the acceptance tests to see if everything is alright with this release. We don't - run them on CI: `pytest -m acceptance` -2. Check if the dependencies of the package are correct, make sure astroid is pinned to +1. Check if the dependencies of the package are correct, make sure astroid is pinned to the latest version. -3. Put the release date into `Changelog` (and `What's new` if it's a major). -4. Generate the new copyright notices for this release: - -```bash -pip3 install copyrite -copyrite --contribution-threshold 1 --change-threshold 3 --backend-type \ -git --aliases=.copyrite_aliases . --jobs=8 -# During the commit pre-commit and pyupgrade will remove the encode utf8 -# automatically -``` - -5. Submit your changes in a merge request. - -6. Make sure the tests are passing on Travis/GithubActions: - https://travis-ci.org/PyCQA/pylint/ - -7. Do the actual release by tagging the master with `vX.Y.Z` (ie `v1.6.12` or `v2.5.3a1` - for example). Travis should deal with the release process once the tag is pushed with - `git push origin --tags` - -8. Go to github, click on "Releases" then on the `vX.Y.Z` tag, choose edit tag, and copy - past the changelog in the description. - -## Manual Release - -Following the previous steps, for a manual release run the following commands: - -```bash -git clean -fdx && find . -name '*.pyc' -delete -python setup.py sdist --formats=gztar bdist_wheel -twine upload dist/* -# don't forget to tag it as well -``` +2. Put the release date into`What's new` if it's a minor version. +3. Install the release dependencies `pip3 install pre-commit tbump` +4. Bump the version and release by using `tbump X.Y.Z --no-push`. +5. Check the result. +6. Push the tag. +7. Go to GitHub, click on "Releases" then on the `vX.Y.Z` tag, choose edit tag, and copy + past the changelog in the description. This will trigger the release to pypi. ## Post release @@ -61,22 +33,29 @@ git push We move issue that were not done in the next milestone and block release only if it's an issue labelled as blocker. -### Files to update after releases +### Back to a dev version -#### setup.cfg +1. Unpin the version of astroid, so it's possible to install a dev version during + development +2. Move back to a dev version for pylint with `tbump`: -- Unpin the version of astroid, so it's possible to install a dev version during - development +```bash +tbump X.Y.Z-dev0 --no-tag --no-push # You can interrupt during copyrite +``` + +Check the result and then upgrade the master branch #### Changelog -- Create a new section, with the name of the release `X.Y.Z+1` or `X.Y+1.0` on the - master branch. +If it was a minor release add a `X.Y+1.0` title following the template: -You need to add the estimated date when it is going to be published. If no date can be -known at that time, we should use `Undefined`. +```text +What's New in pylint x.y.z? +============================ +Release Date: TBA +``` #### Whatsnew -If it's a major release, create a new `What's new in Pylint X.Y+1` document Take a look +If it's a minor release, create a new `What's new in Pylint X.Y+1` document Take a look at the examples from `doc/whatsnew`. diff --git a/requirements_test.txt b/requirements_test.txt index cd1cf3f96..4df235333 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -3,6 +3,7 @@ coveralls~=3.1 coverage~=5.5 pre-commit~=2.13;python_full_version>="3.6.2" +tbump~=6.3.2 pyenchant~=3.2 pytest-cov~=2.12 pytest-profiling~=1.7 diff --git a/script/bump_changelog.py b/script/bump_changelog.py new file mode 100644 index 000000000..e51653056 --- /dev/null +++ b/script/bump_changelog.py @@ -0,0 +1,80 @@ +# ORIGINAL here:https://raw.githubusercontent.com/PyCQA/astroid/master/script/bump_changelog.py +# DO NOT MODIFY DIRECTLY + +""" +This script permits to upgrade the changelog in astroid or pylint when releasing a version. +""" +import argparse +from datetime import datetime +from pathlib import Path + +DEFAULT_CHANGELOG_PATH = Path("ChangeLog") +err = "in the changelog, fix that first!" +TBA_ERROR_MSG = "More than one release date 'TBA' %s" % err +NEW_VERSION_ERROR_MSG = "The text for this version '{version}' did not exists %s" % err +NEXT_VERSION_ERROR_MSG = ( + "The text for the next version '{version}' already exists %s" % err +) + +TODAY = datetime.now() +WHATS_NEW_TEXT = "What's New in astroid" +FULL_WHATS_NEW_TEXT = WHATS_NEW_TEXT + " {version}?" +RELEASE_DATE_TEXT = "Release Date: TBA" +NEW_RELEASE_DATE_MESSAGE = "Release Date: {}".format(TODAY.strftime("%Y-%m-%d")) + + +def main() -> None: + parser = argparse.ArgumentParser(__doc__) + parser.add_argument("version", help="The version we want to release") + args = parser.parse_args() + if "dev" not in args.version: + version = args.version + next_version = get_next_version(version) + run(version, next_version) + + +def get_next_version(version: str) -> str: + new_version = version.split(".") + patch = new_version[2] + reminder = None + if "-" in patch: + patch, reminder = patch.split("-") + patch = str(int(patch) + 1) + new_version[2] = patch if reminder is None else f"{patch}-{reminder}" + return ".".join(new_version) + + +def run(version: str, next_version: str) -> None: + with open(DEFAULT_CHANGELOG_PATH) as f: + content = f.read() + content = transform_content(content, version, next_version) + with open(DEFAULT_CHANGELOG_PATH, "w") as f: + f.write(content) + + +def transform_content(content: str, version: str, next_version: str) -> str: + wn_new_version = FULL_WHATS_NEW_TEXT.format(version=version) + wn_next_version = FULL_WHATS_NEW_TEXT.format(version=next_version) + # There is only one field where the release date is TBA + assert content.count(RELEASE_DATE_TEXT) == 1, TBA_ERROR_MSG + # There is already a release note for the version we want to release + assert content.count(wn_new_version) == 1, NEW_VERSION_ERROR_MSG.format( + version=version + ) + # There is no release notes for the next version + assert content.count(wn_next_version) == 0, NEXT_VERSION_ERROR_MSG.format( + version=next_version + ) + index = content.find(WHATS_NEW_TEXT) + content = content.replace(RELEASE_DATE_TEXT, NEW_RELEASE_DATE_MESSAGE) + end_content = content[index:] + content = content[:index] + content += wn_next_version + "\n" + content += "=" * len(wn_next_version) + "\n" + content += RELEASE_DATE_TEXT + "\n" * 4 + content += end_content + return content + + +if __name__ == "__main__": + main() diff --git a/tbump.toml b/tbump.toml new file mode 100644 index 000000000..da4f7836b --- /dev/null +++ b/tbump.toml @@ -0,0 +1,47 @@ +github_url = "https://github.com/PyCQA/pylint" + +[version] +current = "2.9.0-dev0" +regex = ''' +^(?P<major>0|[1-9]\d*) +\. +(?P<minor>0|[1-9]\d*) +\. +(?P<patch>0|[1-9]\d*) +(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$ +''' + +[git] +message_template = "Bump pylint to {new_version}, update changelog" +tag_template = "v{new_version}" + +# For each file to patch, add a [[file]] config +# section containing the path of the file, relative to the +# tbump.toml location. +[[file]] +src = "pylint/__pkginfo__.py" + +# You can specify a list of commands to +# run after the files have been patched +# and before the git commit is made +[[before_commit]] +name = "Upgrade changelog" +cmd = "python3 script/bump_changelog.py {new_version}" + +[[before_commit]] +name = "Upgrade copyrights" +cmd = "pip3 install copyrite;copyrite --contribution-threshold 1 --change-threshold 3 --backend-type git --aliases=.copyrite_aliases . --jobs=8" + +[[before_commit]] +name = "Apply pre-commit" +cmd = "pre-commit run --all-files||echo 'Hack so this command does not fail'" + +[[before_commit]] +name = "Acceptance tests" +cmd = "pytest -m acceptance" + +# Or run some commands after the git tag and the branch +# have been pushed: +# [[after_push]] +# name = "publish" +# cmd = "./publish.sh" |
