Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/semantic_release/cli/commands/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,7 @@ def version( # noqa: C901
no_verify = runtime.no_git_verify
opts = runtime.global_cli_options
gha_output = VersionGitHubActionsOutput(
gh_client=(
hvcs_client
if isinstance(hvcs_client, Github)
else Github(hvcs_client.remote_url(use_token=False))
),
gh_client=hvcs_client if isinstance(hvcs_client, Github) else None,
mode=(
PersistenceMode.TEMPORARY
if opts.noop or (not commit_changes and not create_tag)
Expand Down Expand Up @@ -553,7 +549,8 @@ def version( # noqa: C901

# Update GitHub Actions output value with new version & set delayed write
gha_output.version = new_version
ctx.call_on_close(gha_output.write_if_possible)
if isinstance(hvcs_client, Github):
ctx.call_on_close(gha_output.write_if_possible)

# Make string variant of version or appropriate tag as necessary
version_to_print = str(new_version) if not print_only_tag else new_version.as_tag()
Expand Down
10 changes: 8 additions & 2 deletions src/semantic_release/cli/github_actions_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class VersionGitHubActionsOutput:

def __init__(
self,
gh_client: Github,
gh_client: Github | None = None,
mode: PersistenceMode = PersistenceMode.PERMANENT,
released: bool | None = None,
version: Version | None = None,
Expand Down Expand Up @@ -106,6 +106,12 @@ def prev_version(self, value: Version) -> None:
raise TypeError("output 'prev_version' should be a Version")
self._prev_version = value

@property
def gh_client(self) -> Github:
if not self._gh_client:
raise ValueError("GitHub client not set, cannot create links")
return self._gh_client

def to_output_text(self) -> str:
missing: set[str] = set()
if self.version is None:
Expand All @@ -128,7 +134,7 @@ def to_output_text(self) -> str:
"version": str(self.version),
"tag": self.tag,
"is_prerelease": str(self.is_prerelease).lower(),
"link": self._gh_client.create_release_url(self.tag) if self.tag else "",
"link": self.gh_client.create_release_url(self.tag) if self.tag else "",
"previous_version": str(self.prev_version) if self.prev_version else "",
"commit_sha": self.commit_sha if self.commit_sha else "",
}
Expand Down
Loading