fix: prevent empty releases in sdk release script

This commit is contained in:
Chirag Aggarwal 2025-10-10 13:26:55 +05:30
parent a8b9d75b2a
commit d6fc2806dc

View file

@ -280,6 +280,20 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
continue;
}
// Check if the latest commit on the target branch already has a release
$latestCommitCommand = 'gh api repos/' . $repoName . '/commits/' . $releaseTarget . ' --jq ".sha" 2>/dev/null';
$latestCommitSha = trim(\shell_exec($latestCommitCommand) ?? '');
if (!empty($latestCommitSha)) {
$commitReleasesCommand = 'gh api repos/' . $repoName . '/releases --jq ".[] | select(.target_commitish == \"' . $releaseTarget . '\") | .tag_name" 2>/dev/null | head -n 1';
$existingCommitRelease = trim(\shell_exec($commitReleasesCommand) ?? '');
if (!empty($existingCommitRelease)) {
Console::warning("Latest commit on {$releaseTarget} already has a release ({$existingCommitRelease}) for {$language['name']} SDK, skipping to avoid empty release...");
continue;
}
}
$previousVersion = '';
$tagListCommand = 'gh release list --repo "' . $repoName . '" --limit 1 --json tagName --jq ".[0].tagName" 2>&1';
$previousVersion = trim(\shell_exec($tagListCommand) ?? '');