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
28 changes: 22 additions & 6 deletions bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ function bumpPhpPackages(string $version, bool $isMajor): void
*/
function cleanUpAfterRelease(): void
{
// We want to still be able to `require tempest/package:dev-main`, so we need
// to update back all composer files to use `dev-main` instead of a fixed version.
executeCommands('./vendor/bin/monorepo-builder bump-interdependency dev-main');
$devVersion = sprintf("%s-dev", getCurrentBranch());

// We want to still be able to `require tempest/package:X.x-dev`, so we need
// to update back all composer files to use the dev version instead of a fixed version.
executeCommands("./vendor/bin/monorepo-builder bump-interdependency {$devVersion}");

// Finds all `composer.json` files in `packages/`, and revert the `tempest/highlight` dependency to the saved version
setPhpDependencyVersion(
Expand Down Expand Up @@ -145,7 +147,7 @@ function updateChangelog(string $version): void
/**
* Ensure the release script can run.
*/
function performPreReleaseChecks(string $remote, string $branch): void
function performPreReleaseChecks(string $remote): void
{
if (empty(shell_exec('which bun'))) {
throw new Exception('This script requires `bun` to be installed.');
Expand All @@ -155,6 +157,12 @@ function performPreReleaseChecks(string $remote, string $branch): void
throw new Exception('Repository must be in a clean state to release.');
}

$branch = getCurrentBranch();

if (! preg_match('/^\d+\.x$/', $branch)) {
throw new Exception("You must be on a version branch to release. Current branch is {$branch}.");
}

if (! str_starts_with(shell_exec('git rev-parse --abbrev-ref --symbolic-full-name @{u}'), "{$remote}/{$branch}")) {
throw new Exception("You must be on the {$remote}/{$branch} branch to release.");
}
Expand Down Expand Up @@ -205,7 +213,7 @@ function triggerSubsplit(): void
'Accept' => 'application/vnd.github+json',
'X-GitHub-Api-Version' => '2022-11-28',
],
body: Json\encode(['ref' => 'main']),
body: Json\encode(['ref' => getCurrentBranch()]),
);

if (! $response->status->isSuccessful()) {
Expand All @@ -222,6 +230,14 @@ function getCurrentVersion(): string
return exec('git describe --tags --abbrev=0');
}

/**
* Gets the current git branch name.
*/
function getCurrentBranch(): string
{
return trim(shell_exec('git rev-parse --abbrev-ref HEAD') ?? '');
}

/**
* Suggests a semver-valid version.
*/
Expand Down Expand Up @@ -344,7 +360,7 @@ function ensureTagDoesNotExist(string $version): void
try {
ConsoleApplication::boot();

performPreReleaseChecks('origin', 'main');
performPreReleaseChecks('origin');

$console = get(Console::class);
$console->writeln();
Expand Down
15 changes: 9 additions & 6 deletions packages/console/src/Exceptions/ConsoleExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ public function handle(Throwable $throwable): void

$this->console->writeln();
} else {
$this->console
->writeln('<style="fg-blue bold">#0</style> ' . $this->formatTrace($throwable->getTrace()[0]))
->writeln('<style="fg-blue bold">#1</style> ' . $this->formatTrace($throwable->getTrace()[1]))
->writeln()
->writeln(' <style="dim">Run with -v to show more.</style>')
->writeln();
$this->console->writeln('<style="fg-blue bold">#0</style> ' . $this->formatTrace($throwable->getTrace()[0]));

if (count($throwable->getTrace()) > 1) {
$this->console->writeln('<style="fg-blue bold">#1</style> ' . $this->formatTrace($throwable->getTrace()[1]));
}

$this->console->writeln();
$this->console->writeln(' <style="dim">Run with -v to show more.</style>');
$this->console->writeln();
}
} finally {
$exitCode = $throwable instanceof HasExitCode
Expand Down