You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
throw new Error(`Failed to check if tag ${tagName} exists: ${error.message}`);
128
+
}
129
+
};
130
+
131
+
// Find the first available tag, bumping the minor/patch if the computed one is taken.
132
+
// This handles the case where a release failed half-way and left a tag behind.
133
+
const MAX_ATTEMPTS = 10;
134
+
let releaseTag;
135
+
for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
136
+
const candidate = `v${major}.${minor}.${patch}`;
137
+
if (!(await tagExists(candidate))) {
138
+
releaseTag = candidate;
139
+
break;
140
+
}
141
+
console.log(`Tag ${candidate} already exists – bumping version and retrying…`);
142
+
// For patch releases keep bumping the patch number.
143
+
// For minor/major releases bump the minor number (patch is already 0).
144
+
switch (releaseType) {
145
+
case 'patch':
146
+
patch += 1;
147
+
break;
148
+
case 'minor':
149
+
minor += 1;
150
+
break;
151
+
case 'major':
152
+
minor += 1;
153
+
break;
154
+
}
122
155
}
123
-
124
-
// Also check if tag exists in git (in case release was deleted but tag remains)
125
-
try {
126
-
await github.rest.git.getRef({
127
-
owner: context.repo.owner,
128
-
repo: context.repo.repo,
129
-
ref: `tags/${releaseTag}`
130
-
});
131
-
// If we get here, the tag exists
132
-
core.setFailed(`Git tag ${releaseTag} already exists in the repository. Cannot create duplicate tag. Please delete the existing tag or use a different version.`);
156
+
157
+
if (!releaseTag) {
158
+
core.setFailed(`Could not find an available release tag after ${MAX_ATTEMPTS} attempts. Please check existing tags and releases.`);
133
159
return;
134
-
} catch (error) {
135
-
// 404 means tag doesn't exist, which is what we want
@@ -72,11 +68,11 @@ function buildForecastIssueBody(report, options) {
72
68
: []),
73
69
...(zeroProjectedWithSamples>0
74
70
? [
75
-
"> [!TIP]",
76
-
`> ${zeroProjectedWithSamples}${zeroWorkflowWord}${zeroWorkflowVerb} sampled runs but forecast ET is 0. This usually indicates missing token usage in cached run summaries for sampled runs.`,
77
-
"> Increase the warm-up scope with `gh aw logs --start-date -30d --count <larger value>` if this persists.",
78
-
"",
79
-
]
71
+
"> [!TIP]",
72
+
`> ${zeroProjectedWithSamples}${zeroWorkflowWord}${zeroWorkflowVerb} sampled runs but forecast ET is 0. This usually indicates missing token usage in cached run summaries for sampled runs.`,
73
+
"> Increase the warm-up scope with `gh aw logs --start-date -30d --count <larger value>` if this persists.",
.mockRejectedValueOnce(newError("Issue is already a sub-issue of the specified issue."));
129
+
mockGithub.graphql.mockResolvedValueOnce({repository: {issue: {parent: null}}}).mockRejectedValueOnce(newError("Issue is already a sub-issue of the specified issue."));
0 commit comments