fix: canonicalize release image references

This commit is contained in:
KoalaDev
2026-08-25 03:01:28 +02:00
parent 3b3ac723ed
commit e88fe40314
5 changed files with 47 additions and 4 deletions
+18
View File
@@ -64,6 +64,21 @@ export function parseRemoteMain(text) {
return match[1];
}
export function validateReleaseWorkflowContract(text) {
const workflow = String(text);
const image = 'ghcr.io/shik3i/koalasync';
if (!workflow.includes(`IMAGE: ${image}`)) {
throw new Error(`release workflow must define the lowercase canonical image ${image}`);
}
for (const reference of ['images: ${{ env.IMAGE }}', 'subject-name: ${{ env.IMAGE }}']) {
if (!workflow.includes(reference)) throw new Error(`release workflow must use ${reference}`);
}
if (/ghcr\.io\/\$\{\{\s*github\.repository\s*\}\}/u.test(workflow)) {
throw new Error('release workflow must not derive a Docker image from case-preserving github.repository');
}
return image;
}
function assertCleanTree() {
const status = capture('git', ['status', '--porcelain=v1']);
if (status) throw new Error(`release gate requires a clean working tree:\n${status}`);
@@ -120,6 +135,9 @@ async function smokeRelayImage(image) {
export async function runReleaseGate({ version, candidate }) {
assertCleanTree();
validateReleaseSourceVersion(version, repoRoot);
validateReleaseWorkflowContract(fs.readFileSync(
path.join(repoRoot, '.github/workflows/release.yml'), 'utf8'
));
if (!candidate) assertFinalMainChecks();
const lock = JSON.parse(fs.readFileSync(path.join(repoRoot, 'package-lock.json'), 'utf8'));