Skip to content

Commit 159d29f

Browse files
committed
Allows to pass two additional parameters
- Branch name from witch the tag is going to be created upon releasing - Description for the release
1 parent 1bd81e0 commit 159d29f

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

main.go

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ func init() {
4747

4848
var usage string = `Github release tool.
4949
Usage:
50-
gh-release <user/repo> <tag> <files>
50+
gh-release <user/repo> <tag> <branch> <description> <files>
5151
5252
<files> can be specified using glob patterns.
5353
`
5454

5555
func main() {
56-
if len(os.Args) < 4 {
56+
if len(os.Args) < 6 {
5757
log.Fatal(usage)
5858
}
5959

@@ -72,29 +72,31 @@ Please refer to https://help.github.com/articles/creating-an-access-token-for-co
7272
GithubRepo = userRepo[1]
7373
GithubAPIEndpoint = fmt.Sprintf("https://api.github.com/repos/%s/%s", GithubUser, GithubRepo)
7474

75-
filepaths, err := filepath.Glob(os.Args[3])
75+
filepaths, err := filepath.Glob(os.Args[5])
7676
if err != nil {
7777
log.Fatalf("Error: Invalid glob pattern: %s\n", os.Args[3])
7878
}
7979

8080
tag := os.Args[2]
81+
branch := os.Args[3]
82+
desc := os.Args[4]
8183

82-
CreateRelease(tag, filepaths)
84+
CreateRelease(tag, branch, desc, filepaths)
8385
log.Println("Done")
8486
}
8587

8688
// Creates a Github Release, attaching the given files as release assets
8789
// 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) {
8991
endpoint := fmt.Sprintf("%s/releases", GithubAPIEndpoint)
9092

9193
release := Release{
9294
TagName: tag,
9395
Name: tag,
9496
Prerelease: false,
9597
Draft: false,
96-
Branch: "master",
97-
Body: "Changelog (TODO)",
98+
Branch: branch,
99+
Body: desc,
98100
}
99101

100102
releaseData, err := json.Marshal(release)
@@ -152,18 +154,6 @@ func CreateRelease(tag string, filepaths []string) {
152154
wg.Wait()
153155
}
154156

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-
167157
func fileSize(file *os.File) (int64, error) {
168158
stat, err := file.Stat()
169159
if err != nil {

0 commit comments

Comments
 (0)