address asset upload warning (#134)

* bump version

* address asset upload warning

* refactor to new octokit api, work around release asset upload api

* format upload url

* unminify to debug

* try alt constructor

* utilize formatted upload url

* authorize upload

* pass token explicitly

* address conflicting uploads

* remove debugging artifacts
This commit is contained in:
Doug Tangren 2021-08-08 00:28:01 -04:00 committed by GitHub
parent 59c3b48916
commit 003621c2ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 273 additions and 218 deletions

View file

@ -1,7 +1,15 @@
import { paths, parseConfig, isTag, unmatchedPatterns } from "./util";
import {
paths,
parseConfig,
isTag,
unmatchedPatterns,
uploadUrl
} from "./util";
import { release, upload, GitHubReleaser } from "./github";
import { getOctokit } from "@actions/github";
import { setFailed, setOutput } from "@actions/core";
import { GitHub } from "@actions/github";
import { GitHub, getOctokitOptions } from "@actions/github/lib/utils";
import { env } from "process";
async function run() {
@ -23,11 +31,14 @@ async function run() {
throw new Error(`⚠️ There were unmatched files`);
}
}
GitHub.plugin([
require("@octokit/plugin-throttling"),
require("@octokit/plugin-retry")
]);
const gh = new GitHub(config.github_token, {
// const oktokit = GitHub.plugin(
// require("@octokit/plugin-throttling"),
// require("@octokit/plugin-retry")
// );
const gh = getOctokit(config.github_token, {
//new oktokit(
throttle: {
onRateLimit: (retryAfter, options) => {
console.warn(
@ -47,15 +58,23 @@ async function run() {
}
}
});
let rel = await release(config, new GitHubReleaser(gh));
//);
const rel = await release(config, new GitHubReleaser(gh));
if (config.input_files) {
const files = paths(config.input_files);
if (files.length == 0) {
console.warn(`🤔 ${config.input_files} not include valid file.`);
}
const currentAsserts = rel.assets;
await Promise.all(
files.map(async path => {
await upload(gh, rel.upload_url, path);
await upload(
config,
gh,
uploadUrl(rel.upload_url),
path,
currentAsserts
);
})
).catch(error => {
throw error;