Skip to content

Commit

Permalink
Change: ⚠️ Merge prepare and release CLI (#643)
Browse files Browse the repository at this point in the history
* Change: Drop preamble from generated changelog text

Drop
```
 # Changelog

All notable changes to this project will be documented in this file.
```

* Add: Add release CLI parser test for empty git tag prefix

* Change: Add new arguments from prepare to release CLI

Add --release-type, --local and --conventional-commits-config to release
CLI. This will allow to merge the prepare functionality into release.

* Change: Merge prepare into release command

Extend the release CLI to include the functionality of the prepare CLI.
With this change no intermediate prepare command is required to create a
release anymore.

Additionally no changelog file is written to the disk anymore.

To test the release it is possible to run release locally by adding the
`--local` argument where only commits and tags are created but not
pushed to a remote repo and no release is published at GitHub.

* Remove: Remove pontos-release prepare CLI

The functionality of the prepare CLI got merged into release and is
obsolete now.
  • Loading branch information
bjoernricks authored Feb 28, 2023
1 parent 7d794b3 commit d2ab17c
Show file tree
Hide file tree
Showing 8 changed files with 1,303 additions and 1,224 deletions.
6 changes: 1 addition & 5 deletions pontos/changelog/conventional_commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,7 @@ def _build_changelog(
"""

# changelog header
changelog = [
"# Changelog\n",
"All notable changes to this project "
"will be documented in this file.\n",
]
changelog = []
if next_version:
changelog.append(
f"## [{next_version}] - {date.today().isoformat()}"
Expand Down
81 changes: 18 additions & 63 deletions pontos/release/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@

from pontos.release.helper import ReleaseType

from .prepare import prepare
from .release import release
from .sign import sign

DEFAULT_CHANGELOG_CONFIG_FILE = "changelog.toml"
DEFAULT_SIGNING_KEY = "0ED1E580"


Expand Down Expand Up @@ -80,77 +78,21 @@ def parse_args(args) -> Tuple[str, str, Namespace]:
required=True,
)

prepare_parser = subparsers.add_parser("prepare")
prepare_parser.set_defaults(func=prepare)
prepare_parser.add_argument(
"--release-version",
help="Version for the created release. Must be PEP 440 compliant."
"Implicitly sets --release-type version.",
action=ReleaseVersionAction,
)

version_group = prepare_parser.add_mutually_exclusive_group()
version_group.add_argument(
"--calendar",
dest="release_type",
help=(
"Automatically calculate calendar release version, from current"
" version and date. Deprecated, user --release-type "
f"{ReleaseType.CALENDAR.value} instead."
),
const=ReleaseType.CALENDAR,
action="store_const",
)
version_group.add_argument(
"--patch",
dest="release_type",
help="Release next patch version: "
"e.g. x.x.3 -> x.x.4. Deprecated, "
f"use --release-type {ReleaseType.PATCH.value} instead.",
const=ReleaseType.PATCH,
action="store_const",
)
version_group.add_argument(
release_parser = subparsers.add_parser("release")
release_parser.set_defaults(func=release)
release_parser.add_argument(
"--release-type",
help="Select the release type for calculating the release version. "
f"Possible choices are: {to_choices(ReleaseType)}.",
type=enum_type(ReleaseType),
)

prepare_parser.add_argument(
"--git-signing-key",
help="The key to sign the commits and tag for a release",
)
prepare_parser.add_argument(
"--git-tag-prefix",
default="v",
help="Prefix for git tag versions. Default: %(default)s",
)
prepare_parser.add_argument(
"--space",
default="greenbone",
help="User/Team name in github",
)
prepare_parser.add_argument(
"--project",
help="The github project",
)
prepare_parser.add_argument(
"--conventional-commits-config",
dest="cc_config",
default=Path(DEFAULT_CHANGELOG_CONFIG_FILE),
type=Path,
help="Conventional commits config file (toml), including conventions.",
)

release_parser = subparsers.add_parser("release")
release_parser.set_defaults(func=release)
release_parser.add_argument(
"--release-version",
help=(
"Will release changelog as version. Must be PEP 440 compliant. "
"default: lookup version in project definition."
),
action=ReleaseVersionAction,
)

release_parser.add_argument(
Expand Down Expand Up @@ -183,6 +125,19 @@ def parse_args(args) -> Tuple[str, str, Namespace]:
default="greenbone",
help="User/Team name in github",
)
release_parser.add_argument(
"--local",
action="store_true",
help="Only create release changes locally and do not upload them to a "
"remote repository. Also do not create a GitHub release.",
)
release_parser.add_argument(
"--conventional-commits-config",
dest="cc_config",
type=Path,
help="Conventional commits config file (toml), including conventions."
" If not set defaults are used.",
)

sign_parser = subparsers.add_parser("sign")
sign_parser.set_defaults(func=sign)
Expand Down Expand Up @@ -222,7 +177,7 @@ def parse_args(args) -> Tuple[str, str, Namespace]:
)
parsed_args = parser.parse_args(args)

if parsed_args.func is prepare:
if parsed_args.func in (release,):
# check for release-type
if not getattr(parsed_args, "release_type"):
parser.error("--release-type is required.")
Expand Down
229 changes: 0 additions & 229 deletions pontos/release/prepare.py

This file was deleted.

Loading

0 comments on commit d2ab17c

Please sign in to comment.