error handling
This commit is contained in:
parent
e197e56931
commit
6fa875df0b
2 changed files with 18 additions and 14 deletions
|
@ -37,23 +37,24 @@ exports.upload = (gh, url, path) => __awaiter(void 0, void 0, void 0, function*
|
|||
});
|
||||
});
|
||||
exports.release = (config, gh) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
let [owner, repo] = config.github_repository.split("/");
|
||||
const [owner, repo] = config.github_repository.split("/");
|
||||
const tag = config.github_ref.replace("refs/tags/", "");
|
||||
try {
|
||||
let release = yield gh.repos.getReleaseByTag({
|
||||
owner,
|
||||
repo,
|
||||
tag: config.github_ref
|
||||
tag
|
||||
});
|
||||
return release.data;
|
||||
}
|
||||
catch (error) {
|
||||
if (error.status === 404) {
|
||||
console.log("Creating new release...");
|
||||
try {
|
||||
const tag_name = config.github_ref.replace("refs/tags/", "");
|
||||
const name = config.input_name || tag_name;
|
||||
const tag_name = tag;
|
||||
const name = config.input_name || tag;
|
||||
const body = config.input_body;
|
||||
const draft = config.input_draft;
|
||||
console.log(`👩🏭 Creating new GitHub release for tag ${tag_name}...`);
|
||||
let release = yield gh.repos.createRelease({
|
||||
owner,
|
||||
repo,
|
||||
|
@ -65,12 +66,13 @@ exports.release = (config, gh) => __awaiter(void 0, void 0, void 0, function* ()
|
|||
return release.data;
|
||||
}
|
||||
catch (error) {
|
||||
console.log(`created failed with status: ${error.status}`);
|
||||
// presume a race with competing metrix runs
|
||||
console.log(`GitHub release failed with status: ${error.status}`);
|
||||
return exports.release(config, gh);
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log(`Unexpected error fetching github release for tag ${config.github_ref}: ${error}`);
|
||||
console.log(`Unexpected error fetching GitHub release for tag ${config.github_ref}: ${error}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,22 +56,23 @@ export const release = async (
|
|||
config: Config,
|
||||
gh: GitHub
|
||||
): Promise<Release> => {
|
||||
let [owner, repo] = config.github_repository.split("/");
|
||||
const [owner, repo] = config.github_repository.split("/");
|
||||
const tag = config.github_ref.replace("refs/tags/", "");
|
||||
try {
|
||||
let release = await gh.repos.getReleaseByTag({
|
||||
owner,
|
||||
repo,
|
||||
tag: config.github_ref
|
||||
tag
|
||||
});
|
||||
return release.data;
|
||||
} catch (error) {
|
||||
if (error.status === 404) {
|
||||
console.log("Creating new release...");
|
||||
try {
|
||||
const tag_name = config.github_ref.replace("refs/tags/", "");
|
||||
const name = config.input_name || tag_name;
|
||||
const tag_name = tag;
|
||||
const name = config.input_name || tag;
|
||||
const body = config.input_body;
|
||||
const draft = config.input_draft;
|
||||
console.log(`👩🏭 Creating new GitHub release for tag ${tag_name}...`);
|
||||
let release = await gh.repos.createRelease({
|
||||
owner,
|
||||
repo,
|
||||
|
@ -82,11 +83,12 @@ export const release = async (
|
|||
});
|
||||
return release.data;
|
||||
} catch (error) {
|
||||
console.log(`created failed with status: ${error.status}`);
|
||||
// presume a race with competing metrix runs
|
||||
console.log(`GitHub release failed with status: ${error.status}`);
|
||||
return release(config, gh);
|
||||
}
|
||||
} else {
|
||||
console.log(`Unexpected error fetching github release for tag ${config.github_ref}: ${error}`);
|
||||
console.log(`Unexpected error fetching GitHub release for tag ${config.github_ref}: ${error}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue