Skip to content

Commit 86d29b3

Browse files
fix: fix asset upload for untagged releases (#74)
1 parent 90b8b8d commit 86d29b3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ cli
104104
return
105105
}
106106

107-
await sendRelease(config, md)
107+
const release = await sendRelease(config, md)
108108

109109
if (args.assets && args.assets.length > 0) {
110-
await uploadAssets(config, args.assets)
110+
await uploadAssets(config, args.assets, release)
111111
}
112112
}
113113
catch (e: any) {

src/github.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export async function sendRelease(
4444
headers,
4545
})
4646
console.log(green(`Released on ${res.html_url}`))
47+
return res
4748
}
4849

4950
function getHeaders(options: ChangelogOptions) {
@@ -151,7 +152,7 @@ export async function hasTagOnGitHub(tag: string, options: ChangelogOptions) {
151152
}
152153
}
153154

154-
export async function uploadAssets(options: ChangelogOptions, assets: string | string[]) {
155+
export async function uploadAssets(options: ChangelogOptions, assets: string | string[], releaseResponse?: any) {
155156
const headers = getHeaders(options)
156157
let assetList: string[] = []
157158
if (typeof assets === 'string') {
@@ -185,7 +186,7 @@ export async function uploadAssets(options: ChangelogOptions, assets: string | s
185186
}
186187

187188
// Get the release by tag to obtain the upload_url
188-
const release = await $fetch(`https://${options.baseUrlApi}/repos/${options.releaseRepo}/releases/tags/${options.to}`, {
189+
const release = releaseResponse ?? await $fetch(`https://${options.baseUrlApi}/repos/${options.releaseRepo}/releases/tags/${options.to}`, {
189190
headers,
190191
})
191192

0 commit comments

Comments
 (0)