drone-gitea-release/main.go

73 lines
1.5 KiB
Go
Raw Permalink Normal View History

package main
import (
"context"
"gitea.dikurium.ch/InnoPeak/drone-gitea-release/plugin"
"github.com/kelseyhightower/envconfig"
2024-07-11 15:09:36 +00:00
log "github.com/sirupsen/logrus"
flag "github.com/spf13/pflag"
)
var args plugin.Args
func init() {
if err := envconfig.Process("", &args); err != nil {
2024-07-11 15:09:36 +00:00
log.Fatalln(err)
}
var (
titleFormat *string = flag.String("title-format", "", "Format to use for the release title")
tagFile *string = flag.String("tag-file", "", "File to check for tag to release")
tagRegex *string = flag.String("tag-regex", "", "Regex pattern to look for tag in tag-file")
notes *string = flag.String("notes", "", "Notes to use in release")
notesFile *string = flag.String("notes-file", "", "File to use for release notes")
logLevel *string = flag.String("log-level", "", "Level for logging")
)
flag.Parse()
if titleFormat != nil && *titleFormat != "" {
args.TitleFormat = *titleFormat
}
if tagFile != nil && *tagFile != "" {
args.TagFile = *tagFile
}
if tagRegex != nil && *tagRegex != "" {
args.TagRegex = *tagRegex
}
if notes != nil && *notes != "" {
args.Notes = *notes
}
if notesFile != nil && *notesFile != "" {
args.NotesFile = *notesFile
}
if logLevel != nil && *logLevel != "" {
args.Level = *logLevel
}
}
func main() {
2024-07-11 15:33:47 +00:00
log.SetFormatter(&log.TextFormatter{
DisableTimestamp: true,
})
switch args.Level {
case "debug":
2024-07-11 15:09:36 +00:00
log.SetLevel(log.DebugLevel)
case "trace":
2024-07-11 15:09:36 +00:00
log.SetLevel(log.TraceLevel)
}
if err := plugin.Exec(context.Background(), args); err != nil {
2024-07-11 15:09:36 +00:00
log.Fatalln(err)
}
}