diff --git a/packages/automatic-releases/src/uploadReleaseArtifacts.ts b/packages/automatic-releases/src/uploadReleaseArtifacts.ts index 70f0a4c6..e2182656 100644 --- a/packages/automatic-releases/src/uploadReleaseArtifacts.ts +++ b/packages/automatic-releases/src/uploadReleaseArtifacts.ts @@ -7,35 +7,40 @@ import md5File from 'md5-file'; export const uploadReleaseArtifacts = async (client: github.GitHub, uploadUrl: string, files: string[]) => { core.startGroup('Uploading release artifacts'); - const paths = await globby(files); + for (const fileGlob of files) { + const paths = await globby(fileGlob); + if (paths.length == 0) { + core.error(`${fileGlob} doesn't match any files`); + } - for (const filePath of paths) { - core.info(`Uploading: ${filePath}`); - const nameWithExt = path.basename(filePath); - const uploadArgs = { - url: uploadUrl, - headers: { - 'content-length': lstatSync(filePath).size, - 'content-type': 'application/octet-stream', - }, - name: nameWithExt, - file: readFileSync(filePath), - }; + for (const filePath of paths) { + core.info(`Uploading: ${filePath}`); + const nameWithExt = path.basename(filePath); + const uploadArgs = { + url: uploadUrl, + headers: { + 'content-length': lstatSync(filePath).size, + 'content-type': 'application/octet-stream', + }, + name: nameWithExt, + file: readFileSync(filePath), + }; - try { - await client.repos.uploadReleaseAsset(uploadArgs); - } catch (err) { - core.info( - `Problem uploading ${filePath} as a release asset (${err.message}). Will retry with the md5 hash appended to the filename.`, - ); - const hash = await md5File(filePath); - const basename = path.basename(filePath, path.extname(filePath)); - const ext = path.extname(filePath); - const newName = ext ? `${basename}-${hash}.${ext}` : `${basename}-${hash}`; - await client.repos.uploadReleaseAsset({ - ...uploadArgs, - name: newName, - }); + try { + await client.repos.uploadReleaseAsset(uploadArgs); + } catch (err) { + core.info( + `Problem uploading ${filePath} as a release asset (${err.message}). Will retry with the md5 hash appended to the filename.`, + ); + const hash = await md5File(filePath); + const basename = path.basename(filePath, path.extname(filePath)); + const ext = path.extname(filePath); + const newName = ext ? `${basename}-${hash}.${ext}` : `${basename}-${hash}`; + await client.repos.uploadReleaseAsset({ + ...uploadArgs, + name: newName, + }); + } } } core.endGroup();