Fix release notes sync race when release is recreated by another workflow
This commit is contained in:
@@ -178,11 +178,32 @@ function main() {
|
|||||||
const notesPath = path.join(tempDir, `${targetTag}-notes.md`);
|
const notesPath = path.join(tempDir, `${targetTag}-notes.md`);
|
||||||
writeFileSync(notesPath, notes);
|
writeFileSync(notesPath, notes);
|
||||||
|
|
||||||
|
const editArgs = ["release", "edit", targetTag, "--repo", args.repo, "--notes-file", notesPath];
|
||||||
|
const createArgs = [
|
||||||
|
"release",
|
||||||
|
"create",
|
||||||
|
targetTag,
|
||||||
|
"--repo",
|
||||||
|
args.repo,
|
||||||
|
"--title",
|
||||||
|
`Paseo ${targetTag}`,
|
||||||
|
"--notes-file",
|
||||||
|
notesPath,
|
||||||
|
"--verify-tag",
|
||||||
|
...(parseReleaseVersion(releaseInfo.version).isPrerelease ? ["--prerelease"] : []),
|
||||||
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (hasRelease(targetTag, args.repo)) {
|
if (hasRelease(targetTag, args.repo)) {
|
||||||
runGh(["release", "edit", targetTag, "--repo", args.repo, "--notes-file", notesPath]);
|
try {
|
||||||
console.log(`Updated release notes for ${targetTag}.`);
|
runGh(editArgs);
|
||||||
return;
|
console.log(`Updated release notes for ${targetTag}.`);
|
||||||
|
return;
|
||||||
|
} catch {
|
||||||
|
console.warn(
|
||||||
|
`Edit failed for ${targetTag} (release may have been recreated by another workflow); falling through to create.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args.createIfMissing) {
|
if (!args.createIfMissing) {
|
||||||
@@ -193,25 +214,13 @@ function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
runGh([
|
runGh(createArgs);
|
||||||
"release",
|
|
||||||
"create",
|
|
||||||
targetTag,
|
|
||||||
"--repo",
|
|
||||||
args.repo,
|
|
||||||
"--title",
|
|
||||||
`Paseo ${targetTag}`,
|
|
||||||
"--notes-file",
|
|
||||||
notesPath,
|
|
||||||
"--verify-tag",
|
|
||||||
...(parseReleaseVersion(releaseInfo.version).isPrerelease ? ["--prerelease"] : []),
|
|
||||||
]);
|
|
||||||
console.log(`Created release ${targetTag} with changelog notes.`);
|
console.log(`Created release ${targetTag} with changelog notes.`);
|
||||||
} catch (createError) {
|
} catch (createError) {
|
||||||
console.warn(
|
console.warn(
|
||||||
`Release creation failed for ${targetTag}; attempting edit in case another workflow created it concurrently.`,
|
`Release creation failed for ${targetTag}; attempting edit in case another workflow created it concurrently.`,
|
||||||
);
|
);
|
||||||
runGh(["release", "edit", targetTag, "--repo", args.repo, "--notes-file", notesPath]);
|
runGh(editArgs);
|
||||||
console.log(`Updated release notes for ${targetTag} after create race.`);
|
console.log(`Updated release notes for ${targetTag} after create race.`);
|
||||||
|
|
||||||
if (createError instanceof Error) {
|
if (createError instanceof Error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user