@@ -13,9 +13,10 @@ import (
1313)
1414
1515type GitConfiguration struct {
16- ApiUrl string
17- Repository string
18- AccessToken string
16+ ApiUrl string
17+ Repository string
18+ AccessToken string
19+ DefaultBranchName string
1920}
2021
2122type NewRelease struct {
@@ -105,7 +106,7 @@ func github_createNextGitHubRelease(conf GitConfiguration, newReleaseVersion str
105106
106107 requestBody , err := json .Marshal (NewRelease {
107108 TagName : newReleaseVersion ,
108- TargetCommitish : "master" ,
109+ TargetCommitish : conf . DefaultBranchName ,
109110 Name : "Release " + newReleaseVersion ,
110111 Body : "" ,
111112 Draft : false ,
@@ -125,21 +126,23 @@ func github_createNextGitHubRelease(conf GitConfiguration, newReleaseVersion str
125126 }
126127
127128 if uploadArtifacts != "" {
128- fmt .Printf ("Uploading artifacts from: %s\n " , uploadArtifacts )
129+ log .Printf ("Uploading artifacts from: %s\n " , uploadArtifacts )
129130
130131 file , err := ioutil .ReadFile (uploadArtifacts )
131132 if err != nil {
132133 log .Fatal (err )
133134 }
134135
135- fmt .Println ("Can read file" )
136- fmt .Println (result ["id" ])
137136 releaseFileName := uploadArtifacts [strings .LastIndex (uploadArtifacts , "/" )+ 1 :]
138137
139- url := fmt .Sprintf ("https://uploads.github.com/repos/%s/releases/%v/assets?name=%s " , conf . Repository , result ["id" ], releaseFileName )
140- fmt . Println ( url )
141- resultTwo := newPostRequest (url , conf .AccessToken , true , file )
138+ uploadUrl := fmt .Sprintf ("%s " , result ["upload_url" ] )
139+ newUploadUrl := strings . Replace ( uploadUrl , "{?name,label}" , "?name=" + releaseFileName , - 1 )
140+ resultTwo := newPostRequest (newUploadUrl , conf .AccessToken , true , file )
142141
143- fmt .Println (resultTwo )
142+ if resultTwo ["name" ] == releaseFileName {
143+ fmt .Println (releaseFileName + " sucsessfully uploaded" )
144+ } else {
145+ fmt .Println ("Somethin went worng at uploading release!" )
146+ }
144147 }
145148}
0 commit comments