mirror of
https://gitea.com/gitea/tea.git
synced 2026-09-10 07:26:33 -04:00
releases create: add --asset argument
allows to specify a file path to be attached to the release. can be specified multiple times
This commit is contained in:
parent
aee6267c9c
commit
f268911eca
|
|
@ -158,7 +158,7 @@ func initCommand(ctx *cli.Context) (*Login, string, string) {
|
|||
return login, owner, repo
|
||||
}
|
||||
|
||||
func getGlobalFlag(ctx *cli.Context, flag string) (string) {
|
||||
func getGlobalFlag(ctx *cli.Context, flag string) string {
|
||||
var val = ctx.String(flag)
|
||||
if val == "" {
|
||||
return ctx.GlobalString(flag)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"os"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
|
||||
|
|
@ -87,6 +89,10 @@ var CmdReleaseCreate = cli.Command{
|
|||
Name: "prerelease, p",
|
||||
Usage: "the release is a prerelease",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "asset, a",
|
||||
Usage: "a list of files to attach to the release",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -106,5 +112,22 @@ func runReleaseCreate(ctx *cli.Context) error {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for _, asset := range ctx.StringSlice("asset") {
|
||||
var file *os.File
|
||||
file, err = os.Open(asset)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
filePath := filepath.Base(asset)
|
||||
|
||||
_, err = login.Client().CreateReleaseAttachment(owner, repo, release.ID, file, filePath)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue