From 6cb53e3acecbfb0d9db0cf2a96a9af144efaaa88 Mon Sep 17 00:00:00 2001 From: bomb-on <0nada0@gmail.com> Date: Fri, 3 Jan 2020 15:51:34 +0000 Subject: [PATCH] Updated lib, fixed typo in workflow error message --- .github/workflows/main.yml | 2 +- lib/github.js | 23 ++++++++++++++++++++++- src/main.ts | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9b7946d..377043a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,6 +21,6 @@ jobs: # Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed. run: | git diff --exit-code --stat -- . ':!node_modules' \ - || (echo "##[error] found changed files after build. please 'npm run build && npm run format'" \ + || (echo "##[error] found changed files after build. please 'npm run build && npm run fmt'" \ "and check in all changes" \ && exit 1) \ No newline at end of file diff --git a/lib/github.js b/lib/github.js index b63dd01..bdd0350 100644 --- a/lib/github.js +++ b/lib/github.js @@ -30,6 +30,9 @@ class GitHubReleaser { createRelease(params) { return this.github.repos.createRelease(params); } + updateRelease(params) { + return this.github.repos.updateRelease(params); + } allReleases(params) { const updatedParams = Object.assign({ per_page: 100 }, params); return this.github.paginate.iterator(this.github.repos.listReleases.endpoint.merge(updatedParams)); @@ -88,11 +91,29 @@ exports.release = (config, releaser) => __awaiter(void 0, void 0, void 0, functi finally { if (e_1) throw e_1.error; } } } - let release = yield releaser.getReleaseByTag({ + let existingRelease = yield releaser.getReleaseByTag({ owner, repo, tag }); + const release_id = existingRelease.data.id; + const target_commitish = existingRelease.data.target_commitish; + const tag_name = tag; + const name = config.input_name || tag; + const body = `${existingRelease.data.body}\n${util_1.releaseBody(config)}`; + const draft = config.input_draft; + const prerelease = config.input_prerelease; + const release = yield releaser.updateRelease({ + owner, + repo, + release_id, + tag_name, + target_commitish, + name, + body, + draft, + prerelease + }); return release.data; } catch (error) { diff --git a/src/main.ts b/src/main.ts index 8541a4c..3985ea1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,9 +31,9 @@ async function run() { }); let rel = await release(config, new GitHubReleaser(gh)); if (config.input_files) { - const files = paths(config.input_files) + const files = paths(config.input_files); if (files.length == 0) { - console.warn(`🤔 ${config.input_files} not include valid file.`) + console.warn(`🤔 ${config.input_files} not include valid file.`); } files.forEach(async path => { await upload(gh, rel.upload_url, path);