File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,17 +29,15 @@ const root = dir
2929const token = process . env . GH_TOKEN ?? process . env . GITHUB_TOKEN
3030if ( ! token ) throw new Error ( "GH_TOKEN or GITHUB_TOKEN is required" )
3131
32- const apiHeaders = {
33- Authorization : `token ${ token } ` ,
34- Accept : "application/vnd.github+json" ,
35- }
36-
37- const releaseRes = await fetch ( `https://api.github.com/repos/${ repo } /releases/${ releaseId } ` , {
38- headers : apiHeaders ,
32+ const rel = await fetch ( `https://api.github.com/repos/${ repo } /releases/${ releaseId } ` , {
33+ headers : {
34+ Authorization : `token ${ token } ` ,
35+ Accept : "application/vnd.github+json" ,
36+ } ,
3937} )
4038
41- if ( ! releaseRes . ok ) {
42- throw new Error ( `Failed to fetch release: ${ releaseRes . status } ${ releaseRes . statusText } ` )
39+ if ( ! rel . ok ) {
40+ throw new Error ( `Failed to fetch release: ${ rel . status } ${ rel . statusText } ` )
4341}
4442
4543type Asset = {
@@ -51,14 +49,6 @@ type Release = {
5149 assets ?: Asset [ ]
5250}
5351
54- const rel = await fetch ( `https://api.github.com/repos/${ repo } /releases/tags/v${ version } ` , {
55- headers : {
56- Authorization : `token ${ token } ` ,
57- Accept : "application/vnd.github+json" ,
58- } ,
59- } )
60- if ( ! rel . ok ) throw new Error ( `Failed to fetch release: ${ rel . status } ${ rel . statusText } ` )
61-
6252const assets = ( ( await rel . json ( ) ) as Release ) . assets ?? [ ]
6353const amap = new Map ( assets . map ( ( item ) => [ item . name , item ] ) )
6454
You can’t perform that action at this time.
0 commit comments