mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-10-10 01:16:12 +00:00
chore: add prettier config (#633)
Signed-off-by: Rui Chen <rui@chenrui.dev>
This commit is contained in:
parent
605f567f95
commit
c8d8e91662
7 changed files with 273 additions and 355 deletions
54
src/main.ts
54
src/main.ts
|
@ -1,24 +1,14 @@
|
|||
import { setFailed, setOutput } from "@actions/core";
|
||||
import { getOctokit } from "@actions/github";
|
||||
import { GitHubReleaser, release, upload } from "./github";
|
||||
import {
|
||||
isTag,
|
||||
parseConfig,
|
||||
paths,
|
||||
unmatchedPatterns,
|
||||
uploadUrl,
|
||||
} from "./util";
|
||||
import { setFailed, setOutput } from '@actions/core';
|
||||
import { getOctokit } from '@actions/github';
|
||||
import { GitHubReleaser, release, upload } from './github';
|
||||
import { isTag, parseConfig, paths, unmatchedPatterns, uploadUrl } from './util';
|
||||
|
||||
import { env } from "process";
|
||||
import { env } from 'process';
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const config = parseConfig(env);
|
||||
if (
|
||||
!config.input_tag_name &&
|
||||
!isTag(config.github_ref) &&
|
||||
!config.input_draft
|
||||
) {
|
||||
if (!config.input_tag_name && !isTag(config.github_ref) && !config.input_draft) {
|
||||
throw new Error(`⚠️ GitHub Releases requires a tag`);
|
||||
}
|
||||
if (config.input_files) {
|
||||
|
@ -44,9 +34,7 @@ async function run() {
|
|||
//new oktokit(
|
||||
throttle: {
|
||||
onRateLimit: (retryAfter, options) => {
|
||||
console.warn(
|
||||
`Request quota exhausted for request ${options.method} ${options.url}`,
|
||||
);
|
||||
console.warn(`Request quota exhausted for request ${options.method} ${options.url}`);
|
||||
if (options.request.retryCount === 0) {
|
||||
// only retries once
|
||||
console.log(`Retrying after ${retryAfter} seconds!`);
|
||||
|
@ -55,9 +43,7 @@ async function run() {
|
|||
},
|
||||
onAbuseLimit: (retryAfter, options) => {
|
||||
// does not retry, only logs a warning
|
||||
console.warn(
|
||||
`Abuse detected for request ${options.method} ${options.url}`,
|
||||
);
|
||||
console.warn(`Abuse detected for request ${options.method} ${options.url}`);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -67,25 +53,15 @@ async function run() {
|
|||
const files = paths(config.input_files);
|
||||
if (files.length == 0) {
|
||||
if (config.input_fail_on_unmatched_files) {
|
||||
throw new Error(
|
||||
`⚠️ ${config.input_files} does not include a valid file.`,
|
||||
);
|
||||
throw new Error(`⚠️ ${config.input_files} does not include a valid file.`);
|
||||
} else {
|
||||
console.warn(
|
||||
`🤔 ${config.input_files} does not include a valid file.`,
|
||||
);
|
||||
console.warn(`🤔 ${config.input_files} does not include a valid file.`);
|
||||
}
|
||||
}
|
||||
const currentAssets = rel.assets;
|
||||
|
||||
const uploadFile = async (path) => {
|
||||
const json = await upload(
|
||||
config,
|
||||
gh,
|
||||
uploadUrl(rel.upload_url),
|
||||
path,
|
||||
currentAssets,
|
||||
);
|
||||
const json = await upload(config, gh, uploadUrl(rel.upload_url), path, currentAssets);
|
||||
if (json) {
|
||||
delete json.uploader;
|
||||
}
|
||||
|
@ -103,12 +79,12 @@ async function run() {
|
|||
}
|
||||
|
||||
const assets = results.filter(Boolean);
|
||||
setOutput("assets", assets);
|
||||
setOutput('assets', assets);
|
||||
}
|
||||
console.log(`🎉 Release ready at ${rel.html_url}`);
|
||||
setOutput("url", rel.html_url);
|
||||
setOutput("id", rel.id.toString());
|
||||
setOutput("upload_url", rel.upload_url);
|
||||
setOutput('url', rel.html_url);
|
||||
setOutput('id', rel.id.toString());
|
||||
setOutput('upload_url', rel.upload_url);
|
||||
} catch (error) {
|
||||
setFailed(error.message);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue