Merge branch 'master' into lunny/ignore

This commit is contained in:
Lunny Xiao 2018-12-05 15:30:40 +08:00 committed by GitHub
commit 5fae6c0d72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 cd gitea
tea login add --name=try --url=https://try.gitea.io --token=xxxxxx tea login add --name=try --url=https://try.gitea.io --token=xxxxxx
tea issues tea issues
tea releases
``` ```
## Contributing ## Contributing

View File

@ -8,6 +8,8 @@ import (
"fmt" "fmt"
"log" "log"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
@ -17,6 +19,9 @@ var CmdReleases = cli.Command{
Usage: "Log in a Gitea server", Usage: "Log in a Gitea server",
Description: `Log in a Gitea server`, Description: `Log in a Gitea server`,
Action: runReleases, Action: runReleases,
Subcommands: []cli.Command{
CmdReleaseCreate,
},
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "login, l", Name: "login, l",
@ -51,3 +56,55 @@ func runReleases(ctx *cli.Context) error {
return nil 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
}