Skip to content

Commit

Permalink
Change: Update release CLI to handle multi language projects
Browse files Browse the repository at this point in the history
With this change it is possible to do releases for projects containing
different language setups.
  • Loading branch information
bjoernricks committed Mar 2, 2023
1 parent 4f69b5b commit 7db80aa
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 147 deletions.
21 changes: 10 additions & 11 deletions pontos/release/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
from pontos.git import Git
from pontos.github.api import GitHubAsyncRESTApi
from pontos.terminal import Terminal
from pontos.version.commands import gather_project
from pontos.version.errors import VersionError
from pontos.version.helper import get_last_release_version
from pontos.version.version import Version, VersionCommand
from pontos.version.project import Project
from pontos.version.version import Version

from .helper import ReleaseType, find_signing_key, get_git_repository_name

Expand All @@ -55,12 +55,12 @@ def __init__(self, terminal: Terminal) -> None:

def _get_release_version(
self,
command: VersionCommand,
project: Project,
release_type: ReleaseType,
release_version: Optional[Version],
) -> Version:
current_version = command.get_current_version()
calculator = command.get_version_calculator()
current_version = project.get_current_version()
calculator = project.get_version_calculator()
if release_type == ReleaseType.CALENDAR:
return calculator.next_calendar_version(current_version)

Expand Down Expand Up @@ -176,14 +176,14 @@ async def run(
self.space = space

try:
command = gather_project()
project = Project.gather_project()
except PontosError as e:
self.terminal.error(f"Unable to determine project settings. {e}")
return ReleaseReturnValue.PROJECT_SETTINGS_NOT_FOUND

try:
release_version = self._get_release_version(
command, release_type, release_version
project, release_type, release_version
)
except VersionError as e:
self.terminal.error(f"Unable to determine release version. {e}")
Expand All @@ -201,7 +201,7 @@ async def run(
return ReleaseReturnValue.ALREADY_TAKEN

try:
updated = command.update_version(release_version)
updated = project.update_version(release_version)

self.terminal.ok(f"Updated version to {release_version}")

Expand Down Expand Up @@ -253,13 +253,12 @@ async def run(
self.terminal.error(str(e))
return ReleaseReturnValue.CREATE_RELEASE_ERROR

calculator = command.get_version_calculator()

if not next_version:
calculator = project.get_version_calculator()
next_version = calculator.next_dev_version(release_version)

try:
updated = command.update_version(next_version)
updated = project.update_version(next_version)
self.terminal.ok(f"Updated version after release to {next_version}")
except VersionError as e:
self.terminal.error(
Expand Down
Loading

0 comments on commit 7db80aa

Please sign in to comment.