From 3509a5c98f9417dd6aceb3697269d7c4c4794410 Mon Sep 17 00:00:00 2001 From: RaviAnand Mohabir Date: Tue, 25 Jun 2024 15:29:33 +0200 Subject: [PATCH] feat: :sparkles: add skip_if_no_notes_file setting --- plugin/plugin.go | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/plugin/plugin.go b/plugin/plugin.go index bcbecec..daad73b 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -23,18 +23,19 @@ type Args struct { // Level defines the plugin log level. Level string `envconfig:"PLUGIN_LOG_LEVEL"` - GiteaUrl string `envconfig:"PLUGIN_GITEA_URL"` - GiteaUsername string `envconfig:"PLUGIN_GITEA_USERNAME"` - GiteaPassword string `envconfig:"PLUGIN_GITEA_PASSWORD"` - Owner string `envconfig:"PLUGIN_OWNER"` - Repo string `envconfig:"PLUGIN_REPO"` - TitleFormat string `envconfig:"PLUGIN_TITLE_FORMAT"` - UseLatestGitTag bool `envconfig:"PLUGIN_USE_LATEST_GIT_TAG" default:"true"` - TagFile string `envconfig:"PLUGIN_TAG_FILE"` - TagRegex string `envconfig:"PLUGIN_TAG_REGEX"` - NotesFile string `envconfig:"PLUGIN_NOTES_FILE"` - Notes string `envconfig:"PLUGIN_NOTES"` - IsPrerelease bool `envconfig:"PLUGIN_IS_PRERELEASE"` + GiteaUrl string `envconfig:"PLUGIN_GITEA_URL"` + GiteaUsername string `envconfig:"PLUGIN_GITEA_USERNAME"` + GiteaPassword string `envconfig:"PLUGIN_GITEA_PASSWORD"` + Owner string `envconfig:"PLUGIN_OWNER"` + Repo string `envconfig:"PLUGIN_REPO"` + TitleFormat string `envconfig:"PLUGIN_TITLE_FORMAT"` + UseLatestGitTag bool `envconfig:"PLUGIN_USE_LATEST_GIT_TAG" default:"true"` + TagFile string `envconfig:"PLUGIN_TAG_FILE"` + TagRegex string `envconfig:"PLUGIN_TAG_REGEX"` + NotesFile string `envconfig:"PLUGIN_NOTES_FILE"` + Notes string `envconfig:"PLUGIN_NOTES"` + IsPrerelease bool `envconfig:"PLUGIN_IS_PRERELEASE"` + SkipIfNoNotesFile bool `envconfig:"PLUGIN_SKIP_IF_NO_NOTES_FILE"` } type TitleTemplateCtx struct { @@ -60,6 +61,10 @@ func Exec(ctx context.Context, args Args) error { content, err := os.ReadFile(args.NotesFile) if err != nil { + if os.IsNotExist(err) && args.SkipIfNoNotesFile { + fmt.Println("No notes file found, skipping release") + return nil + } return fmt.Errorf("error reading notes file %w", err) }