@@ -47,13 +47,13 @@ func init() {
47
47
48
48
var usage string = `Github release tool.
49
49
Usage:
50
- gh-release <user/repo> <tag> <files>
50
+ gh-release <user/repo> <tag> <branch> <description> < files>
51
51
52
52
<files> can be specified using glob patterns.
53
53
`
54
54
55
55
func main () {
56
- if len (os .Args ) < 4 {
56
+ if len (os .Args ) < 6 {
57
57
log .Fatal (usage )
58
58
}
59
59
@@ -72,29 +72,31 @@ Please refer to https://help.github.com/articles/creating-an-access-token-for-co
72
72
GithubRepo = userRepo [1 ]
73
73
GithubAPIEndpoint = fmt .Sprintf ("https://api.github.com/repos/%s/%s" , GithubUser , GithubRepo )
74
74
75
- filepaths , err := filepath .Glob (os .Args [3 ])
75
+ filepaths , err := filepath .Glob (os .Args [5 ])
76
76
if err != nil {
77
77
log .Fatalf ("Error: Invalid glob pattern: %s\n " , os .Args [3 ])
78
78
}
79
79
80
80
tag := os .Args [2 ]
81
+ branch := os .Args [3 ]
82
+ desc := os .Args [4 ]
81
83
82
- CreateRelease (tag , filepaths )
84
+ CreateRelease (tag , branch , desc , filepaths )
83
85
log .Println ("Done" )
84
86
}
85
87
86
88
// Creates a Github Release, attaching the given files as release assets
87
89
// If a release already exist, up in Github, this function will attempt to attach the given files to it
88
- func CreateRelease (tag string , filepaths []string ) {
90
+ func CreateRelease (tag , branch , desc string , filepaths []string ) {
89
91
endpoint := fmt .Sprintf ("%s/releases" , GithubAPIEndpoint )
90
92
91
93
release := Release {
92
94
TagName : tag ,
93
95
Name : tag ,
94
96
Prerelease : false ,
95
97
Draft : false ,
96
- Branch : "master" ,
97
- Body : "Changelog (TODO)" ,
98
+ Branch : branch ,
99
+ Body : desc ,
98
100
}
99
101
100
102
releaseData , err := json .Marshal (release )
@@ -152,18 +154,6 @@ func CreateRelease(tag string, filepaths []string) {
152
154
wg .Wait ()
153
155
}
154
156
155
- // Calculates md5, sha1 and sha512 hashes for each given file
156
- func HashFiles (files []string ) (map [string ]string , error ) {
157
- return nil , nil
158
- }
159
-
160
- // Generates release changelog by comparing the tag provided, against the latest tag pushed up to Github
161
- func changelog (tag string ) string {
162
- endpoint := fmt .Sprintf ("%s/commits" , GithubAPIEndpoint )
163
- log .Println (endpoint )
164
- return ""
165
- }
166
-
167
157
func fileSize (file * os.File ) (int64 , error ) {
168
158
stat , err := file .Stat ()
169
159
if err != nil {
0 commit comments