Skip to content

Commit e60c775

Browse files
wip
1 parent 4f75e5b commit e60c775

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

packages/monorepo/src/Commands/CreateRelease.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public function handle(): int
119119
$newVersion = $this->askForNewVersion($currentVersion);
120120
$this->info("New version: {$newVersion}\n");
121121

122+
// Ask for user token for release authorship
123+
$userToken = $this->askForUserToken();
124+
122125
$missingPackagesResult = $this->packageComparisonService->isNewOrgPackage(array_keys($packages['public']), array_keys($packages['private']), $orgPackages);
123126

124127
// Flatten the missing packages result into a single array
@@ -187,6 +190,7 @@ public function handle(): int
187190
[
188191
'version' => $newVersion,
189192
'packages' => $publicPackagesJson,
193+
'user_token' => $userToken,
190194
]
191195
);
192196
}
@@ -203,6 +207,7 @@ public function handle(): int
203207
[
204208
'version' => $newVersion,
205209
'packages' => $privatePackagesJson,
210+
'user_token' => $userToken,
206211
]
207212
);
208213
}
@@ -393,6 +398,24 @@ public function askForNewVersion(string $currentVersion): string
393398
return $version;
394399
}
395400

401+
public function askForUserToken(): string
402+
{
403+
$this->line("\n🔑 GitHub Release Authorship");
404+
$this->line("To appear as the author of GitHub releases, provide your personal access token.");
405+
$this->line("Leave empty to use bot token (releases will show as created by mooxbot).");
406+
$this->line("Token needs 'public_repo' or 'repo' scope for the target repositories.");
407+
408+
$token = $this->secret('Enter your GitHub personal access token (optional):');
409+
410+
if (empty($token)) {
411+
$this->line("ℹ️ Using bot token - releases will be created by mooxbot");
412+
return '';
413+
} else {
414+
$this->line("✅ Using your token - releases will show you as author");
415+
return $token;
416+
}
417+
}
418+
396419
// Helper methods
397420
private function validateVersionFormat(string $version): bool
398421
{

packages/monorepo/src/Services/GitHubService.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,23 @@ public function getWorkflows(string $org, string $repo): ?array
6868
return $this->fetchJson($url);
6969
}
7070

71+
public function getCurrentUser(): ?array
72+
{
73+
$url = 'https://api.github.com/user';
74+
return $this->fetchJson($url);
75+
}
76+
7177
public function triggerWorkflowDispatch(string $org, string $repo, string $workflowId, string $ref = 'main', array $inputs = []): ?array
7278
{
7379
$url = "https://api.github.com/repos/{$org}/{$repo}/actions/workflows/{$workflowId}/dispatches";
7480

81+
// Automatically add user information to inputs
82+
$user = $this->getCurrentUser();
83+
if ($user && !isset($inputs['user_name']) && !isset($inputs['user_email'])) {
84+
$inputs['user_name'] = $user['name'] ?? $user['login'] ?? 'Unknown User';
85+
$inputs['user_email'] = $user['email'] ?? $user['login'] . '@users.noreply.github.com';
86+
}
87+
7588
$data = [
7689
'ref' => $ref,
7790
];

0 commit comments

Comments
 (0)