Skip to content

Commit 38fdcde

Browse files
committed
refs and cleanup
1 parent fb7cfea commit 38fdcde

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

.github/workflows/milestone-release.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,30 @@ jobs:
7070
});
7171
console.log(`Updated release: ${milestoneTitle}`);
7272
} else {
73-
await github.rest.repos.createRelease({
74-
owner, repo,
75-
tag_name: milestoneTitle,
76-
name: milestoneTitle,
77-
body: body || 'No issues in this milestone yet.',
78-
draft: isDraft
79-
});
80-
console.log(`Created release: ${milestoneTitle}`);
73+
// Check if tag exists before creating release
74+
let tagExists = false;
75+
try {
76+
await github.rest.git.getRef({
77+
owner, repo,
78+
ref: `tags/${milestoneTitle}`
79+
});
80+
tagExists = true;
81+
} catch (error) {
82+
if (error.status !== 404) throw error;
83+
}
84+
85+
if (tagExists) {
86+
await github.rest.repos.createRelease({
87+
owner, repo,
88+
tag_name: milestoneTitle,
89+
name: milestoneTitle,
90+
body: body || 'No issues in this milestone yet.',
91+
draft: isDraft
92+
});
93+
console.log(`Created release: ${milestoneTitle}`);
94+
} else {
95+
console.log(`Skipping release creation: tag '${milestoneTitle}' does not exist`);
96+
}
8197
}
8298
}
8399

0 commit comments

Comments
 (0)