mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
upload changelog asset on release
This commit is contained in:
parent
e7b5c3f046
commit
340b56eda3
@ -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
|
||||||
@ -196,11 +208,13 @@ async function main() {
|
|||||||
const bundlePath = await compressDistBundle()
|
const bundlePath = await compressDistBundle()
|
||||||
|
|
||||||
const changelog = await composeChangelog()
|
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
|
// 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
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user