1
0
mirror of https://gitea.com/gitea/tea.git synced 2024-07-21 03:14:19 -04:00

Add release create (#1)

* add release create

* typo
This commit is contained in:
Lunny Xiao 2018-10-22 02:52:57 +08:00 committed by Lauris BH
parent 9d5cda4bfe
commit b9b653dec3
2 changed files with 58 additions and 0 deletions

View File

@ -19,6 +19,7 @@ git clone git@try.gitea.io:gitea/gitea.git
cd gitea
tea login add --name=try --url=https://try.gitea.io --token=xxxxxx
tea issues
tea releases
```
## Contributing

View File

@ -8,6 +8,8 @@ import (
"fmt"
"log"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli"
)
@ -17,6 +19,9 @@ var CmdReleases = cli.Command{
Usage: "Log in a Gitea server",
Description: `Log in a Gitea server`,
Action: runReleases,
Subcommands: []cli.Command{
CmdReleaseCreate,
},
Flags: []cli.Flag{
cli.StringFlag{
Name: "login, l",
@ -51,3 +56,55 @@ func runReleases(ctx *cli.Context) error {
return nil
}
var CmdReleaseCreate = cli.Command{
Name: "create",
Usage: "Create a release in repository",
Description: `Create a release in repository`,
Action: runReleaseCreate,
Flags: []cli.Flag{
cli.StringFlag{
Name: "tag",
Usage: "release tag name",
},
cli.StringFlag{
Name: "target",
Usage: "release target refs, branch name or commit id",
},
cli.StringFlag{
Name: "title, t",
Usage: "release title to create",
},
cli.StringFlag{
Name: "note, n",
Usage: "release note to create",
},
cli.BoolFlag{
Name: "draft, d",
Usage: "the release is a draft",
},
cli.BoolFlag{
Name: "prerelease, p",
Usage: "the release is a prerelease",
},
},
}
func runReleaseCreate(ctx *cli.Context) error {
login, owner, repo := initCommand(ctx)
_, err := login.Client().CreateRelease(owner, repo, gitea.CreateReleaseOption{
TagName: ctx.String("tag"),
Target: ctx.String("target"),
Title: ctx.String("title"),
Note: ctx.String("note"),
IsDraft: ctx.Bool("draft"),
IsPrerelease: ctx.Bool("prerelease"),
})
if err != nil {
log.Fatal(err)
}
return nil
}