Skip to content
This repository was archived by the owner on May 24, 2019. It is now read-only.

Commit b9b653d

Browse files
lunnylafriks
authored andcommitted
Add release create (#1)
* add release create * typo
1 parent 9d5cda4 commit b9b653d

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ git clone [email protected]:gitea/gitea.git
1919
cd gitea
2020
tea login add --name=try --url=https://try.gitea.io --token=xxxxxx
2121
tea issues
22+
tea releases
2223
```
2324

2425
## Contributing

cmd/releases.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"fmt"
99
"log"
1010

11+
"code.gitea.io/sdk/gitea"
12+
1113
"github.com/urfave/cli"
1214
)
1315

@@ -17,6 +19,9 @@ var CmdReleases = cli.Command{
1719
Usage: "Log in a Gitea server",
1820
Description: `Log in a Gitea server`,
1921
Action: runReleases,
22+
Subcommands: []cli.Command{
23+
CmdReleaseCreate,
24+
},
2025
Flags: []cli.Flag{
2126
cli.StringFlag{
2227
Name: "login, l",
@@ -51,3 +56,55 @@ func runReleases(ctx *cli.Context) error {
5156

5257
return nil
5358
}
59+
60+
var CmdReleaseCreate = cli.Command{
61+
Name: "create",
62+
Usage: "Create a release in repository",
63+
Description: `Create a release in repository`,
64+
Action: runReleaseCreate,
65+
Flags: []cli.Flag{
66+
cli.StringFlag{
67+
Name: "tag",
68+
Usage: "release tag name",
69+
},
70+
cli.StringFlag{
71+
Name: "target",
72+
Usage: "release target refs, branch name or commit id",
73+
},
74+
cli.StringFlag{
75+
Name: "title, t",
76+
Usage: "release title to create",
77+
},
78+
cli.StringFlag{
79+
Name: "note, n",
80+
Usage: "release note to create",
81+
},
82+
cli.BoolFlag{
83+
Name: "draft, d",
84+
Usage: "the release is a draft",
85+
},
86+
cli.BoolFlag{
87+
Name: "prerelease, p",
88+
Usage: "the release is a prerelease",
89+
},
90+
},
91+
}
92+
93+
func runReleaseCreate(ctx *cli.Context) error {
94+
login, owner, repo := initCommand(ctx)
95+
96+
_, err := login.Client().CreateRelease(owner, repo, gitea.CreateReleaseOption{
97+
TagName: ctx.String("tag"),
98+
Target: ctx.String("target"),
99+
Title: ctx.String("title"),
100+
Note: ctx.String("note"),
101+
IsDraft: ctx.Bool("draft"),
102+
IsPrerelease: ctx.Bool("prerelease"),
103+
})
104+
105+
if err != nil {
106+
log.Fatal(err)
107+
}
108+
109+
return nil
110+
}

0 commit comments

Comments
 (0)