-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the '--current-version' option to the 'semverup' command and the '--add-all' flag to 'publish' to avoid needing to use Python package specific files like '_version.py' or 'pyproject.toml'. Signed-off-by: Eva Millán <[email protected]>
- Loading branch information
Showing
4 changed files
with
106 additions
and
22 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 |
---|---|---|
|
@@ -48,7 +48,9 @@ | |
help="Do not remove changelog entries from the repository.") | ||
@click.option('--remote-branch', 'remote_branch', default="master", | ||
help="Remote branch to push. Default 'master'.") | ||
def publish(version, author, remote, only_push, no_cleanup, remote_branch): | ||
@click.option('--add-all', is_flag=True, | ||
help="Add all changed files to the release commit.") | ||
def publish(version, author, remote, only_push, no_cleanup, remote_branch, add_all): | ||
"""Publish a new release. | ||
This script will generate a new release in the repository. | ||
|
@@ -71,6 +73,10 @@ def publish(version, author, remote, only_push, no_cleanup, remote_branch): | |
When '--no-cleanup' argument is specified, do not remove changelog | ||
entries. | ||
By default, the release commit will include the version, pyproject, | ||
release notes, news and authors files. To add all changed files to | ||
the release commit use the `--add-all` flag. | ||
VERSION: version of the new release. | ||
AUTHOR: author of the new release (e.g. John Smith <[email protected]>) | ||
|
@@ -88,7 +94,7 @@ def publish(version, author, remote, only_push, no_cleanup, remote_branch): | |
if not only_push: | ||
if not no_cleanup: | ||
remove_unreleased_changelog_entries(project) | ||
add_release_files(project, version) | ||
add_release_files(project, version, add_all) | ||
commit(project, version, author) | ||
|
||
if remote: | ||
|
@@ -126,28 +132,31 @@ def rollback_add_release_files(project): | |
pass | ||
|
||
|
||
def add_release_files(project, version): | ||
def add_release_files(project, version, add_all): | ||
"""Add to the repository all the files needed to publish a release.""" | ||
|
||
click.echo("Adding files to the release commit...", nl=False) | ||
|
||
# Add version file | ||
version_file = project.version_file | ||
if add_all: | ||
project.repo.add('-A') | ||
else: | ||
# Add version file | ||
version_file = project.version_file | ||
|
||
if not version_file: | ||
rollback_add_release_files(project) | ||
raise click.ClickException("version file not found") | ||
if not version_file: | ||
rollback_add_release_files(project) | ||
raise click.ClickException("version file not found") | ||
|
||
project.repo.add(version_file) | ||
project.repo.add(version_file) | ||
|
||
# Add pyproject.toml file | ||
pyproject_file = project.pyproject_file | ||
# Add pyproject.toml file | ||
pyproject_file = project.pyproject_file | ||
|
||
if not pyproject_file: | ||
rollback_add_release_files(project) | ||
raise click.ClickException("pyproject file not found") | ||
if not pyproject_file: | ||
rollback_add_release_files(project) | ||
raise click.ClickException("pyproject file not found") | ||
|
||
project.repo.add(pyproject_file) | ||
project.repo.add(pyproject_file) | ||
|
||
# Add release notes file | ||
notes_file = os.path.join(project.releases_path, version + '.md') | ||
|
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 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,12 @@ | ||
--- | ||
title: Options for non-Python projects | ||
category: added | ||
author: Eva Millán <[email protected]> | ||
issue: null | ||
notes: > | ||
Add the `--current-version=VERSION_NUMBER` argument to | ||
the `semverup` command to avoid looking for the version | ||
in a `_version.py` file. | ||
To include all changed files in the release commit, eg. | ||
a `project.json` file where the version was changed | ||
manually, add the `--add-all` flag to the `publish` command. |
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