From 340b56eda3a3e7fd126a8e3c6559dd1408129518 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Thu, 27 Apr 2023 00:48:56 +0000 Subject: [PATCH] upload changelog asset on release --- scripts/release.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/release.js b/scripts/release.js index 8e2e9a83..c9618ce5 100755 --- a/scripts/release.js +++ b/scripts/release.js @@ -97,7 +97,7 @@ async function compressDistBundle() { return outPath } -async function uploadAssets({ release, bundlePath }) { +async function uploadAssets({ release, bundlePath, changelogPath }) { // check if has `noPublish` argument, if true, skip uploading assets if (process.argv.includes("--noPublish")) { console.log("🔥 Skipping upload assets due to `noPublish` argument") @@ -116,10 +116,22 @@ async function uploadAssets({ release, bundlePath }) { data: fs.readFileSync(bundlePath) }) + const changelogAsset = await octokit.repos.uploadReleaseAsset({ + release_id: release.id, + owner: repo.split("/")[0], + repo: repo.split("/")[1], + name: "changelog.md", + data: fs.readFileSync(changelogPath) + }) + if (!appDistAsset) { return false } + if (!changelogAsset) { + return false + } + console.log("⚒ Uploading assets done!") return true @@ -196,11 +208,13 @@ async function main() { const bundlePath = await compressDistBundle() const changelog = await composeChangelog() + + const changelogFilepath = path.resolve(changelogsPath, `v${currentVersion.split(".").join("-")}.md`) - console.log("📝 Writing changelog to file...") + console.log(`📝 Writing changelog to file > ${changelogFilepath}`) // write changelog to file - fs.writeFileSync(path.resolve(changelogsPath, `v${currentVersion.replace(".", "-")}.md`), changelog) + fs.writeFileSync(changelogFilepath, changelog) const release = await createGithubRelease({ version: currentVersion, @@ -212,7 +226,7 @@ async function main() { if (!release) return - const assets = await uploadAssets({ release, bundlePath }).catch((err) => { + const assets = await uploadAssets({ release, bundlePath, changelogFilepath }).catch((err) => { console.error(`🆘 Failed to upload asset: ${err}`, err.response) return false })