@@ -43,6 +43,7 @@ type Release struct {
4343}
4444
4545var verFlag bool
46+ var prereleaseFlag bool
4647
4748func init () {
4849 log .SetFlags (0 )
@@ -59,6 +60,7 @@ func init() {
5960 }
6061
6162 flag .BoolVar (& verFlag , "version" , false , "-version" )
63+ flag .BoolVar (& prereleaseFlag , "prerelease" , false , "-prerelease" )
6264 flag .Parse ()
6365}
6466
@@ -77,6 +79,7 @@ Parameters:
7779
7880Options:
7981 -version: Displays version
82+ -prerelease: Identify the release as a prerelease
8083
8184Environment variables:
8285 DEBUG: Allows you to run github-release in debugging mode. DO NOT do this if you are attempting to upload big files.
@@ -139,7 +142,15 @@ Please refer to https://help.github.com/articles/creating-an-access-token-for-co
139142 branch := flag .Arg (2 )
140143 desc := flag .Arg (3 )
141144
142- CreateRelease (tag , branch , desc , filepaths )
145+ release := Release {
146+ TagName : tag ,
147+ Name : tag ,
148+ Prerelease : prereleaseFlag ,
149+ Draft : false ,
150+ Branch : branch ,
151+ Body : desc ,
152+ }
153+ publishRelease (release , filepaths )
143154 log .Println ("Done" )
144155}
145156
@@ -173,8 +184,6 @@ func uploadFile(uploadURL, path string) {
173184// CreateRelease creates a Github Release, attaching the given files as release assets
174185// If a release already exist, up in Github, this function will attempt to attach the given files to it.
175186func CreateRelease (tag , branch , desc string , filepaths []string ) {
176- endpoint := fmt .Sprintf ("%s/releases" , githubAPIEndpoint )
177-
178187 release := Release {
179188 TagName : tag ,
180189 Name : tag ,
@@ -183,7 +192,11 @@ func CreateRelease(tag, branch, desc string, filepaths []string) {
183192 Branch : branch ,
184193 Body : desc ,
185194 }
195+ publishRelease (release , filepaths )
196+ }
186197
198+ func publishRelease (release Release , filepaths []string ) {
199+ endpoint := fmt .Sprintf ("%s/releases" , githubAPIEndpoint )
187200 releaseData , err := json .Marshal (release )
188201 if err != nil {
189202 log .Fatalln (err )
@@ -196,7 +209,7 @@ func CreateRelease(tag, branch, desc string, filepaths []string) {
196209 if err != nil && data != nil {
197210 log .Println (err )
198211 log .Println ("Trying again assuming release already exists." )
199- endpoint = fmt .Sprintf ("%s/releases/tags/%s" , githubAPIEndpoint , tag )
212+ endpoint = fmt .Sprintf ("%s/releases/tags/%s" , githubAPIEndpoint , release . TagName )
200213 data , err = doRequest ("GET" , endpoint , "application/json" , nil , int64 (0 ))
201214 }
202215
0 commit comments