Commit b120018e authored by totten's avatar totten

bin/glr - autocreate release

parent 7df2def4
......@@ -24,15 +24,38 @@ $c['gitlab()'] = function($url, Credentials $cred, HandlerStack $guzzleHandler)
return $client;
};
$c['app']->command('upload [-N|--dry-run] projectUrl verNum assets*', function ($projectUrl, $verNum, $assets, SymfonyStyle $io, $gitlab, $input) {
// Ensure that the release exists.
$c['release()'] = function($client, $verNum, SymfonyStyle $io) {
try {
$client->get('releases/' . urlencode($verNum) . '/');
}
catch (\Exception $e) {
$client->post('releases', [
'form_params' => [
'name' => $verNum,
'tag_name' => $verNum,
'description' => $verNum,
],
]);
}
};
$c['app']->command('upload [-N|--dry-run] projectUrl verNum assets*', function ($projectUrl, $verNum, $assets, SymfonyStyle $io, $gitlab, $input, $release) {
$verbose = function($data) use ($io) { return $io->isVerbose() ? toJSON($data) : ''; };
$client = $gitlab($projectUrl);
assertThat(preg_match('/^\d[0-9a-z\.\-\+]*$/', $verNum));
$io->writeln(sprintf("<info>Release project <comment>%s</comment> at version <comment>%s</comment>:\n<comment> * %s</comment></info>", $projectUrl, $verNum, implode("\n * ", $assets)));
$existingAssets = fromJSON($client->get('releases/' . urlencode($verNum) . '/assets/links'));
$existingAssets = index(['name'], $existingAssets);
$release($client, $verNum);
try {
$existingAssets = fromJSON($client->get('releases/' . urlencode($verNum) . '/assets/links'));
$existingAssets = index(['name'], $existingAssets);
}
catch (\Exception $e) {
$existingAssets = [];
}
foreach ($assets as $asset) {
assertThat(file_exists($asset), "File $asset does not exist");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment