@@ -7,35 +7,40 @@ import md5File from 'md5-file';
7
7
8
8
export const uploadReleaseArtifacts = async ( client : github . GitHub , uploadUrl : string , files : string [ ] ) => {
9
9
core . startGroup ( 'Uploading release artifacts' ) ;
10
- const paths = await globby ( files ) ;
10
+ for ( const fileGlob of files ) {
11
+ const paths = await globby ( fileGlob ) ;
12
+ if ( paths . length == 0 ) {
13
+ core . error ( `${ fileGlob } doesn't match any files` ) ;
14
+ }
11
15
12
- for ( const filePath of paths ) {
13
- core . info ( `Uploading: ${ filePath } ` ) ;
14
- const nameWithExt = path . basename ( filePath ) ;
15
- const uploadArgs = {
16
- url : uploadUrl ,
17
- headers : {
18
- 'content-length' : lstatSync ( filePath ) . size ,
19
- 'content-type' : 'application/octet-stream' ,
20
- } ,
21
- name : nameWithExt ,
22
- file : readFileSync ( filePath ) ,
23
- } ;
16
+ for ( const filePath of paths ) {
17
+ core . info ( `Uploading: ${ filePath } ` ) ;
18
+ const nameWithExt = path . basename ( filePath ) ;
19
+ const uploadArgs = {
20
+ url : uploadUrl ,
21
+ headers : {
22
+ 'content-length' : lstatSync ( filePath ) . size ,
23
+ 'content-type' : 'application/octet-stream' ,
24
+ } ,
25
+ name : nameWithExt ,
26
+ file : readFileSync ( filePath ) ,
27
+ } ;
24
28
25
- try {
26
- await client . repos . uploadReleaseAsset ( uploadArgs ) ;
27
- } catch ( err ) {
28
- core . info (
29
- `Problem uploading ${ filePath } as a release asset (${ err . message } ). Will retry with the md5 hash appended to the filename.` ,
30
- ) ;
31
- const hash = await md5File ( filePath ) ;
32
- const basename = path . basename ( filePath , path . extname ( filePath ) ) ;
33
- const ext = path . extname ( filePath ) ;
34
- const newName = ext ? `${ basename } -${ hash } .${ ext } ` : `${ basename } -${ hash } ` ;
35
- await client . repos . uploadReleaseAsset ( {
36
- ...uploadArgs ,
37
- name : newName ,
38
- } ) ;
29
+ try {
30
+ await client . repos . uploadReleaseAsset ( uploadArgs ) ;
31
+ } catch ( err ) {
32
+ core . info (
33
+ `Problem uploading ${ filePath } as a release asset (${ err . message } ). Will retry with the md5 hash appended to the filename.` ,
34
+ ) ;
35
+ const hash = await md5File ( filePath ) ;
36
+ const basename = path . basename ( filePath , path . extname ( filePath ) ) ;
37
+ const ext = path . extname ( filePath ) ;
38
+ const newName = ext ? `${ basename } -${ hash } .${ ext } ` : `${ basename } -${ hash } ` ;
39
+ await client . repos . uploadReleaseAsset ( {
40
+ ...uploadArgs ,
41
+ name : newName ,
42
+ } ) ;
43
+ }
39
44
}
40
45
}
41
46
core . endGroup ( ) ;
0 commit comments