Skip to content

Commit d56a2ee

Browse files
wip action and release command
1 parent ef70744 commit d56a2ee

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

.github/workflows/split.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ jobs:
3131
echo "Raw packages file:"
3232
cat packages.json
3333
34+
# Check if this is a prerelease version
35+
VERSION="${{ github.event.inputs.version }}"
36+
if [[ $VERSION =~ -(alpha|beta|rc) ]]; then
37+
echo "🚧 Detected prerelease version: $VERSION"
38+
IS_PRERELEASE=true
39+
else
40+
echo "✅ Detected stable version: $VERSION"
41+
IS_PRERELEASE=false
42+
fi
43+
3444
echo "Parsed packages:"
3545
jq -r 'to_entries[] | "\(.key): Messages=[\(.value["release-message"] | join(", "))] Stability=\(.value["minimum-stability"] // "unknown")"' packages.json
3646
@@ -40,8 +50,10 @@ jobs:
4050
4151
# Set core version from input (exact version)
4252
echo "core-version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
53+
echo "is-prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
4354
4455
echo "Package list for matrix: $package_list"
56+
echo "Is prerelease: $IS_PRERELEASE"
4557
4658
split:
4759
needs: prepare

packages/monorepo/src/Commands/CreateRelease.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -670,17 +670,31 @@ protected function changeGithubWorkflow(array $newPackages, string $version): vo
670670
}
671671
}
672672

673-
protected function createRelease(string $version): void
673+
protected function createRelease(string $version): void
674674
{
675675
$repo = config('monorepo.public_repo', 'mooxphp/moox');
676-
677-
$this->line("Creating monorepo release for version: {$version}");
678-
679-
$result = $this->githubService->createRelease($repo, $version, "Release version {$version}, initial release");
680-
676+
677+
// Detect if this is a prerelease
678+
$isPrerelease = preg_match('/-(alpha|beta|rc)\b/i', $version);
679+
$releaseType = $isPrerelease ? 'prerelease' : 'stable release';
680+
681+
$this->line("Creating monorepo {$releaseType} for version: {$version}");
682+
683+
// Create appropriate release body
684+
$releaseBody = $isPrerelease
685+
? "Prerelease version {$version} - Please test thoroughly before using in production."
686+
: "Release version {$version}";
687+
688+
$result = $this->githubService->createRelease($repo, $version, $releaseBody);
689+
681690
if ($result !== null) {
682-
$this->line('✅ Successfully created monorepo release');
691+
$icon = $isPrerelease ? '🚧' : '';
692+
$this->line("{$icon} Successfully created monorepo {$releaseType}");
683693
$this->line("Release created: v{$version}");
694+
695+
if ($isPrerelease) {
696+
$this->warn("⚠️ This is a prerelease - users will need to explicitly install this version");
697+
}
684698
} else {
685699
$this->error('❌ Failed to create monorepo release');
686700
}

packages/monorepo/src/Services/GitHubService.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,53 +50,55 @@ public function postJson(string $url, array $data = []): ?array
5050
$errorMessage = $response->body();
5151
$statusCode = $response->status();
5252
\Log::error("GitHub API POST ({$url}) request failed: Status {$statusCode}, Message: {$errorMessage}");
53-
53+
5454
return null;
5555
}
5656

5757
public function getOrgHostedRunners(string $org): ?array
5858
{
5959
$url = "https://api.github.com/orgs/{$org}/actions/hosted-runners";
60-
6160
return $this->fetchJson($url);
6261
}
6362

6463
public function getWorkflows(string $org, string $repo): ?array
6564
{
6665
$url = "https://api.github.com/repos/{$org}/{$repo}/actions/workflows";
67-
6866
return $this->fetchJson($url);
6967
}
7068

69+
7170
public function triggerWorkflowDispatch(string $org, string $repo, string $workflowId, string $ref = 'main', array $inputs = []): ?array
7271
{
7372
$url = "https://api.github.com/repos/{$org}/{$repo}/actions/workflows/{$workflowId}/dispatches";
74-
73+
7574
$data = [
7675
'ref' => $ref,
7776
];
78-
79-
if (! empty($inputs)) {
77+
78+
if (!empty($inputs)) {
8079
$data['inputs'] = $inputs;
8180
}
82-
81+
8382
return $this->postJson($url, $data);
8483
}
8584

86-
public function createRelease(string $repoFullName, string $version, ?string $body = null, string $targetCommitish = 'main'): ?array
85+
public function createRelease(string $repoFullName, string $version, string $body = null, string $targetCommitish = 'main'): ?array
8786
{
8887
$url = "https://api.github.com/repos/{$repoFullName}/releases";
89-
88+
89+
// Detect if this is a prerelease (alpha, beta, rc)
90+
$isPrerelease = preg_match('/-(alpha|beta|rc)\b/i', $version);
91+
9092
$data = [
9193
'tag_name' => "v{$version}",
9294
'target_commitish' => $targetCommitish,
9395
'name' => $version,
9496
'body' => $body ?? "Release version {$version}",
9597
'draft' => false,
96-
'prerelease' => false,
98+
'prerelease' => $isPrerelease,
9799
'generate_release_notes' => false,
98100
];
99-
101+
100102
return $this->postJson($url, $data);
101103
}
102104

0 commit comments

Comments
 (0)