Skip to content

Commit

Permalink
Fix release name setting.
Browse files Browse the repository at this point in the history
Signed-off-by: owent <[email protected]>
  • Loading branch information
owent committed Mar 27, 2023
1 parent 0ee8d41 commit a3eb4ba
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
19 changes: 9 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -20844,15 +20844,15 @@ 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,
page: 1,
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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
19 changes: 9 additions & 10 deletions lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a3eb4ba

Please sign in to comment.