From a3eb4ba7ad5bdeec3131d3ab3a1a9cdc7720b296 Mon Sep 17 00:00:00 2001 From: owent Date: Mon, 27 Mar 2023 19:49:19 +0800 Subject: [PATCH] Fix release name setting. Signed-off-by: owent --- lib/index.js | 19 +++++++++---------- lib/index.js.map | 19 +++++++++---------- src/index.ts | 18 +++++++++--------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/lib/index.js b/lib/index.js index 3c28bb1..1d968bc 100755 --- a/lib/index.js +++ b/lib/index.js @@ -20714,9 +20714,6 @@ async function run() { // action_github.context.repo.repo = upload-to-github-release-test // action_github.context.repo.owner = xresloader let release_tag_name = "Release-" + action_github.context.sha.substring(0, 8); - if (!release_name) { - release_name = release_tag_name; - } if (custom_tag_name) { release_tag_name = custom_tag_name; } @@ -20762,6 +20759,9 @@ async function run() { match_branch[1] + "-" + action_github.context.sha.substring(0, 8); } } + if (!release_name) { + release_name = release_tag_name; + } const upload_files = []; for (const upload_pattern of upload_files_pattern) { const select_files = await (0, globby_1.globby)(upload_pattern, { absolute: true, onlyFiles: true }); @@ -20844,7 +20844,7 @@ async function run() { // We can not get a draft release by getReleaseByTag, so we try to find the draft release with the same name by if (!(deploy_release && deploy_release.data)) { let try_draft_release; - console.log(`Try to get draft release ${release_tag_name} from ${target_owner}/${target_repo}`); + console.log(`Try to get draft release name ${release_name} or tag name ${release_tag_name} from ${target_owner}/${target_repo}`); try_draft_release = await octokit.rest.repos.listReleases({ owner: target_owner, repo: target_repo, @@ -20852,7 +20852,7 @@ async function run() { per_page: find_draft_release_count, }).then((rsp) => { for (const release of rsp.data || []) { - if (release.name == release_tag_name || + if (release.name == release_name || release.tag_name == release_tag_name) { return { data: release, @@ -20863,7 +20863,7 @@ async function run() { } return undefined; }).catch((error) => { - console.log(`Try to get draft release ${release_tag_name} from ${target_owner}/${target_repo} : ${error.message}`); + console.log(`Try to get draft release name ${release_name} or tag name ${release_tag_name} from ${target_owner}/${target_repo} : ${error.message}`); return undefined; }); if (try_draft_release && try_draft_release.headers) { @@ -20898,12 +20898,11 @@ async function run() { upload_url = deploy_release.data.upload_url; release_url = deploy_release.data.url; release_commitish = deploy_release.data.target_commitish; - release_name = deploy_release.data.name || ""; + if (deploy_release.data.name) { + release_name = deploy_release.data.name; + } release_id = deploy_release.data.id; } - else { - release_name = release_tag_name; - } // https://developer.github.com/v3/repos/releases/#create-a-release if (deploy_release && deploy_release.data) { if (is_verbose) { diff --git a/lib/index.js.map b/lib/index.js.map index 3c28bb1..1d968bc 100755 --- a/lib/index.js.map +++ b/lib/index.js.map @@ -20714,9 +20714,6 @@ async function run() { // action_github.context.repo.repo = upload-to-github-release-test // action_github.context.repo.owner = xresloader let release_tag_name = "Release-" + action_github.context.sha.substring(0, 8); - if (!release_name) { - release_name = release_tag_name; - } if (custom_tag_name) { release_tag_name = custom_tag_name; } @@ -20762,6 +20759,9 @@ async function run() { match_branch[1] + "-" + action_github.context.sha.substring(0, 8); } } + if (!release_name) { + release_name = release_tag_name; + } const upload_files = []; for (const upload_pattern of upload_files_pattern) { const select_files = await (0, globby_1.globby)(upload_pattern, { absolute: true, onlyFiles: true }); @@ -20844,7 +20844,7 @@ async function run() { // We can not get a draft release by getReleaseByTag, so we try to find the draft release with the same name by if (!(deploy_release && deploy_release.data)) { let try_draft_release; - console.log(`Try to get draft release ${release_tag_name} from ${target_owner}/${target_repo}`); + console.log(`Try to get draft release name ${release_name} or tag name ${release_tag_name} from ${target_owner}/${target_repo}`); try_draft_release = await octokit.rest.repos.listReleases({ owner: target_owner, repo: target_repo, @@ -20852,7 +20852,7 @@ async function run() { per_page: find_draft_release_count, }).then((rsp) => { for (const release of rsp.data || []) { - if (release.name == release_tag_name || + if (release.name == release_name || release.tag_name == release_tag_name) { return { data: release, @@ -20863,7 +20863,7 @@ async function run() { } return undefined; }).catch((error) => { - console.log(`Try to get draft release ${release_tag_name} from ${target_owner}/${target_repo} : ${error.message}`); + console.log(`Try to get draft release name ${release_name} or tag name ${release_tag_name} from ${target_owner}/${target_repo} : ${error.message}`); return undefined; }); if (try_draft_release && try_draft_release.headers) { @@ -20898,12 +20898,11 @@ async function run() { upload_url = deploy_release.data.upload_url; release_url = deploy_release.data.url; release_commitish = deploy_release.data.target_commitish; - release_name = deploy_release.data.name || ""; + if (deploy_release.data.name) { + release_name = deploy_release.data.name; + } release_id = deploy_release.data.id; } - else { - release_name = release_tag_name; - } // https://developer.github.com/v3/repos/releases/#create-a-release if (deploy_release && deploy_release.data) { if (is_verbose) { diff --git a/src/index.ts b/src/index.ts index 67bf1f2..1f081df 100644 --- a/src/index.ts +++ b/src/index.ts @@ -105,9 +105,6 @@ async function run() { // action_github.context.repo.owner = xresloader let release_tag_name = "Release-" + action_github.context.sha.substring(0, 8); - if (!release_name) { - release_name = release_tag_name; - } if (custom_tag_name) { release_tag_name = custom_tag_name; } else if ((with_branches && with_branches.length > 0) || with_tags) { @@ -161,6 +158,9 @@ async function run() { match_branch[1] + "-" + action_github.context.sha.substring(0, 8); } } + if (!release_name) { + release_name = release_tag_name; + } const upload_files: string[] = []; for (const upload_pattern of upload_files_pattern) { @@ -339,7 +339,7 @@ async function run() { if (!(deploy_release && deploy_release.data)) { let try_draft_release: typeof deploy_release; console.log( - `Try to get draft release ${release_tag_name} from ${target_owner}/${target_repo}` + `Try to get draft release name ${release_name} or tag name ${release_tag_name} from ${target_owner}/${target_repo}` ); try_draft_release = await octokit.rest.repos.listReleases({ owner: target_owner, @@ -349,7 +349,7 @@ async function run() { }).then((rsp) => { for (const release of rsp.data || []) { if ( - release.name == release_tag_name || + release.name == release_name || release.tag_name == release_tag_name ) { return { @@ -363,7 +363,7 @@ async function run() { return undefined; }).catch((error) => { console.log( - `Try to get draft release ${release_tag_name} from ${target_owner}/${target_repo} : ${error.message}` + `Try to get draft release name ${release_name} or tag name ${release_tag_name} from ${target_owner}/${target_repo} : ${error.message}` ); return undefined; @@ -427,10 +427,10 @@ async function run() { upload_url = deploy_release.data.upload_url; release_url = deploy_release.data.url; release_commitish = deploy_release.data.target_commitish; - release_name = deploy_release.data.name || ""; + if (deploy_release.data.name) { + release_name = deploy_release.data.name; + } release_id = deploy_release.data.id; - } else { - release_name = release_tag_name; } // https://developer.github.com/v3/repos/releases/#create-a-release if (deploy_release && deploy_release.data) {