@@ -36,39 +36,39 @@ const UPLOAD_RELEASE_URL = `https://uploads.github.com/repos/${REPO}/releases/{i
3636const RELEASE_BODY = `Released at {date}\r\n\r\nRelease for commit: https://github.com/uEssentials/uEssentials/commit/${ COMMIT } (${ process . env [ 'APPVEYOR_REPO_COMMIT_MESSAGE' ] } )` ;
3737
3838function createRelease ( version ) {
39- let res = request ( 'POST' , CREATE_RELEASE_URL , {
40- headers : {
41- 'User-Agent' : 'node'
42- } ,
43- body : JSON . stringify ( {
44- tag_name : version ,
45- target_commitish : "master" ,
46- name : version ,
47- body : RELEASE_BODY . replace ( "{date}" , new Date ( ) . toUTCString ( ) ) ,
48- draft : false ,
49- prerelease : true
50- } )
51- } ) ;
52- if ( res . body . toString ( ) . indexOf ( 'already_exists' ) > - 1 ) {
53- console . log ( `Release for commit ${ COMMIT } already exists. Exiting...` ) ;
54- process . exit ( 0 ) ;
55- }
56- return JSON . parse ( res . getBody ( 'utf8' ) ) ;
39+ let res = request ( 'POST' , CREATE_RELEASE_URL , {
40+ headers : {
41+ 'User-Agent' : 'node'
42+ } ,
43+ body : JSON . stringify ( {
44+ tag_name : version ,
45+ target_commitish : "master" ,
46+ name : version ,
47+ body : RELEASE_BODY . replace ( "{date}" , new Date ( ) . toUTCString ( ) ) ,
48+ draft : false ,
49+ prerelease : true
50+ } )
51+ } ) ;
52+ if ( res . body . toString ( ) . indexOf ( 'already_exists' ) > - 1 ) {
53+ console . log ( `Release for commit ${ COMMIT } already exists. Exiting...` ) ;
54+ process . exit ( 0 ) ;
55+ }
56+ return JSON . parse ( res . getBody ( 'utf8' ) ) ;
5757}
5858
5959function uploadAsset ( releaseInfo , filePath , fileName ) {
60- let id = releaseInfo [ 'id' ] ;
61- if ( ! id ) {
62- throw 'id == undefined'
63- }
64- let res = request ( 'POST' , UPLOAD_RELEASE_URL . replace ( '{id}' , id ) . replace ( '{name}' , fileName ) , {
65- headers : {
66- 'User-Agent' : 'node' ,
67- 'Content-Type' : 'application/zip'
68- } ,
69- body : fs . readFileSync ( filePath )
70- } ) ;
71- return JSON . parse ( res . getBody ( 'utf8' ) ) ;
60+ let id = releaseInfo [ 'id' ] ;
61+ if ( ! id ) {
62+ throw 'id == undefined'
63+ }
64+ let res = request ( 'POST' , UPLOAD_RELEASE_URL . replace ( '{id}' , id ) . replace ( '{name}' , fileName ) , {
65+ headers : {
66+ 'User-Agent' : 'node' ,
67+ 'Content-Type' : 'application/zip'
68+ } ,
69+ body : fs . readFileSync ( filePath )
70+ } ) ;
71+ return JSON . parse ( res . getBody ( 'utf8' ) ) ;
7272}
7373
7474// Create a "blank commit" to "organize" releases.
@@ -96,11 +96,11 @@ uploadAsset(createRelease(`build-${shortSha}`), 'deploy/uEssentials.zip', `uEsse
9696
9797// Add 'Download available' status
9898request ( "POST" , `https://api.github.com/repos/uessentials/uessentials/statuses/${ COMMIT } ?access_token=${ ACCESS_TOKEN } ` , {
99- headers : { 'User-Agent' : 'node' } ,
100- body : JSON . stringify ( {
101- state : "success" ,
102- target_url : `https://github.com/uEssentials/Builds/releases/tag/build-${ shortSha } ` ,
103- description : "available!" ,
104- context : "Download"
105- } )
99+ headers : { 'User-Agent' : 'node' } ,
100+ body : JSON . stringify ( {
101+ state : "success" ,
102+ target_url : `https://github.com/uEssentials/Builds/releases/tag/build-${ shortSha } ` ,
103+ description : "available!" ,
104+ context : "Download"
105+ } )
106106} ) ;
0 commit comments