upload changelog asset on release

This commit is contained in:
SrGooglo 2023-04-27 00:48:56 +00:00
parent e7b5c3f046
commit 340b56eda3

View File

@ -97,7 +97,7 @@ async function compressDistBundle() {
return outPath return outPath
} }
async function uploadAssets({ release, bundlePath }) { async function uploadAssets({ release, bundlePath, changelogPath }) {
// check if has `noPublish` argument, if true, skip uploading assets // check if has `noPublish` argument, if true, skip uploading assets
if (process.argv.includes("--noPublish")) { if (process.argv.includes("--noPublish")) {
console.log("🔥 Skipping upload assets due to `noPublish` argument") console.log("🔥 Skipping upload assets due to `noPublish` argument")
@ -116,10 +116,22 @@ async function uploadAssets({ release, bundlePath }) {
data: fs.readFileSync(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) { if (!appDistAsset) {
return false return false
} }
if (!changelogAsset) {
return false
}
console.log("⚒ Uploading assets done!") console.log("⚒ Uploading assets done!")
return true return true
@ -197,10 +209,12 @@ async function main() {
const changelog = await composeChangelog() const changelog = await composeChangelog()
console.log("📝 Writing changelog to file...") const changelogFilepath = path.resolve(changelogsPath, `v${currentVersion.split(".").join("-")}.md`)
console.log(`📝 Writing changelog to file > ${changelogFilepath}`)
// write changelog to file // write changelog to file
fs.writeFileSync(path.resolve(changelogsPath, `v${currentVersion.replace(".", "-")}.md`), changelog) fs.writeFileSync(changelogFilepath, changelog)
const release = await createGithubRelease({ const release = await createGithubRelease({
version: currentVersion, version: currentVersion,
@ -212,7 +226,7 @@ async function main() {
if (!release) return 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) console.error(`🆘 Failed to upload asset: ${err}`, err.response)
return false return false
}) })