Skip to content

Commit 29d5e61

Browse files
[changelog] Restore plain text workflow outputs (#149) (#150)
* [changelog] Restore plain text workflow outputs (#149) * Update wiki submodule pointer for PR #150 --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1988b19 commit 29d5e61

8 files changed

Lines changed: 79 additions & 15 deletions

File tree

.github/wiki

Submodule wiki updated from de61917 to 20da8b9

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
### Fixed
2121

2222
- Stabilize logger and process-queue test expectations in CI by making GitHub Actions output detection deterministic during the PHPUnit suite (#33)
23+
- Restore raw text output for `changelog:next-version` and `changelog:show` so changelog release workflows can keep capturing versions and redirecting release notes safely (#149)
2324

2425
## [1.16.0] - 2026-04-20
2526

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ the same structured payload indented for manual inspection in a terminal.
183183
`--pretty-json` also implies JSON output, so there is no need to pass both
184184
flags together. In agent environments, DevTools can also switch to JSON
185185
automatically when the runtime is detected as agent-driven. For
186-
`changelog:show`, the default text mode still prints the raw release-notes
187-
body so release workflows can keep piping it directly into GitHub releases.
186+
`changelog:next-version` and `changelog:show`, the default text mode still
187+
prints raw values so release workflows can keep capturing semantic versions
188+
and piping rendered release notes directly into GitHub releases.
188189

189190
Progress output is disabled by default on the commands that support transient
190191
rendering, and `--progress` re-enables it for human-readable terminal runs.

docs/commands/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ Behavior
124124
- ``changelog:next-version --json`` emits the inferred semantic version
125125
as the ``message`` plus structured context describing the inspected changelog
126126
path and optional current version;
127+
- ``changelog:next-version`` prints only the inferred semantic version in text
128+
mode so workflows can capture it safely in shell variables;
127129
- ``changelog:next-version`` uses ``Removed`` or ``Deprecated`` entries for a
128130
major bump, ``Added`` or ``Changed`` entries for a minor bump, and otherwise
129131
falls back to a patch bump;

src/Console/Command/ChangelogNextVersionCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8989
$currentVersion = $input->getOption('current-version');
9090
$nextVersion = $this->changelogManager->inferNextVersion($path, $currentVersion);
9191

92+
// This command is consumed via shell capture in changelog.yml, so
93+
// plain-text mode MUST keep emitting the raw version string.
94+
if (! $this->isJsonOutput($input)) {
95+
$output->writeln($nextVersion);
96+
97+
return self::SUCCESS;
98+
}
99+
92100
return $this->success(
93101
$nextVersion,
94102
$input,

src/Console/Command/ChangelogShowCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9393
$version,
9494
);
9595

96+
// This command feeds redirected release-notes files in changelog.yml,
97+
// so plain-text mode MUST keep writing the rendered body directly.
98+
if (! $this->isJsonOutput($input)) {
99+
$output->write($releaseNotes);
100+
101+
return self::SUCCESS;
102+
}
103+
96104
return $this->success(
97105
$releaseNotes,
98106
$input,

tests/Console/Command/ChangelogNextVersionCommandTest.php

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use PHPUnit\Framework\Attributes\UsesTrait;
2929
use PHPUnit\Framework\TestCase;
3030
use Prophecy\PhpUnit\ProphecyTrait;
31+
use Prophecy\Argument;
3132
use Prophecy\Prophecy\ObjectProphecy;
3233
use Psr\Log\LoggerInterface;
3334
use ReflectionMethod;
@@ -77,6 +78,10 @@ protected function setUp(): void
7778
->willReturn('CHANGELOG.md');
7879
$this->input->getOption('current-version')
7980
->willReturn(null);
81+
$this->input->getOption('json')
82+
->willReturn(false);
83+
$this->input->getOption('pretty-json')
84+
->willReturn(false);
8085
$this->filesystem->getAbsolutePath('CHANGELOG.md')
8186
->willReturn('/repo/CHANGELOG.md');
8287

@@ -91,8 +96,26 @@ protected function setUp(): void
9196
* @return void
9297
*/
9398
#[Test]
94-
public function executeWillReturnSuccessWithTheInferredVersion(): void
99+
public function executeWillWriteTheInferredVersionToOutputInPlainTextMode(): void
95100
{
101+
$this->changelogManager->inferNextVersion('/repo/CHANGELOG.md', null)
102+
->willReturn('1.3.0');
103+
$this->output->writeln('1.3.0')
104+
->shouldBeCalled();
105+
$this->logger->log(Argument::cetera())
106+
->shouldNotBeCalled();
107+
108+
self::assertSame(ChangelogNextVersionCommand::SUCCESS, $this->invokeExecute());
109+
}
110+
111+
/**
112+
* @return void
113+
*/
114+
#[Test]
115+
public function executeWillLogTheInferredVersionWhenJsonOutputIsRequested(): void
116+
{
117+
$this->input->getOption('json')
118+
->willReturn(true);
96119
$this->changelogManager->inferNextVersion('/repo/CHANGELOG.md', null)
97120
->willReturn('1.3.0');
98121
$this->logger->log(
@@ -112,21 +135,16 @@ public function executeWillReturnSuccessWithTheInferredVersion(): void
112135
* @return void
113136
*/
114137
#[Test]
115-
public function executeWillPassTheExplicitCurrentVersionToInference(): void
138+
public function executeWillPassTheExplicitCurrentVersionToInferenceInPlainTextMode(): void
116139
{
117140
$this->input->getOption('current-version')
118141
->willReturn('1.2.3');
119142
$this->changelogManager->inferNextVersion('/repo/CHANGELOG.md', '1.2.3')
120143
->willReturn('2.0.0');
121-
$this->logger->log(
122-
'info',
123-
'2.0.0',
124-
[
125-
'input' => $this->input->reveal(),
126-
'current_version' => '1.2.3',
127-
'next_version' => '2.0.0',
128-
],
129-
)->shouldBeCalled();
144+
$this->output->writeln('2.0.0')
145+
->shouldBeCalled();
146+
$this->logger->log(Argument::cetera())
147+
->shouldNotBeCalled();
130148

131149
self::assertSame(ChangelogNextVersionCommand::SUCCESS, $this->invokeExecute());
132150
}

tests/Console/Command/ChangelogShowCommandTest.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use PHPUnit\Framework\Attributes\UsesTrait;
2929
use PHPUnit\Framework\TestCase;
3030
use Prophecy\PhpUnit\ProphecyTrait;
31+
use Prophecy\Argument;
3132
use Prophecy\Prophecy\ObjectProphecy;
3233
use Psr\Log\LoggerInterface;
3334
use ReflectionMethod;
@@ -66,6 +67,10 @@ protected function setUp(): void
6667

6768
$this->input->getOption('file')
6869
->willReturn('CHANGELOG.md');
70+
$this->input->getOption('json')
71+
->willReturn(false);
72+
$this->input->getOption('pretty-json')
73+
->willReturn(false);
6974
$this->input->getArgument('version')
7075
->willReturn('1.2.0');
7176
$this->filesystem->getAbsolutePath('CHANGELOG.md')
@@ -82,10 +87,31 @@ protected function setUp(): void
8287
* @return void
8388
*/
8489
#[Test]
85-
public function executeWillLogReleaseNotes(): void
90+
public function executeWillWriteReleaseNotesToOutputInPlainTextMode(): void
8691
{
8792
$releaseNotes = "### Added\n\n- Ship it\n";
8893

94+
$this->changelogManager->renderReleaseNotes('/repo/CHANGELOG.md', '1.2.0')
95+
->willReturn($releaseNotes)
96+
->shouldBeCalled();
97+
$this->output->write($releaseNotes)
98+
->shouldBeCalled();
99+
$this->logger->log(Argument::cetera())
100+
->shouldNotBeCalled();
101+
102+
self::assertSame(ChangelogShowCommand::SUCCESS, $this->invokeExecute());
103+
}
104+
105+
/**
106+
* @return void
107+
*/
108+
#[Test]
109+
public function executeWillLogReleaseNotesWhenJsonOutputIsRequested(): void
110+
{
111+
$releaseNotes = "### Added\n\n- Ship it\n";
112+
113+
$this->input->getOption('json')
114+
->willReturn(true);
89115
$this->changelogManager->renderReleaseNotes('/repo/CHANGELOG.md', '1.2.0')
90116
->willReturn($releaseNotes)
91117
->shouldBeCalled();

0 commit comments

Comments
 (0)