From 6e18b3ce0d4351a045cc0622ec0fb7ca616c7ade Mon Sep 17 00:00:00 2001 From: Ryan Albert Date: Tue, 19 Nov 2024 15:15:38 -0800 Subject: [PATCH] feat: add published tag --- internal/actions/release.go | 10 +++++++++- internal/actions/runWorkflow.go | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/actions/release.go b/internal/actions/release.go index ced654d..9cec0a1 100644 --- a/internal/actions/release.go +++ b/internal/actions/release.go @@ -163,6 +163,8 @@ func addCurrentBranchTagging(g *git.Git, latestRelease map[string]releases.Langu } var sources, targets []string + // a tag that is applied if the target contributing is published + var isPublished bool branch := strings.TrimPrefix(os.Getenv("GITHUB_REF"), "refs/heads/") workflow, err := configuration.GetWorkflowAndValidateLanguages(true) if err != nil { @@ -172,6 +174,7 @@ func addCurrentBranchTagging(g *git.Git, latestRelease map[string]releases.Langu // the tagging library treats targets synonymously with code samples if specificTarget := environment.SpecifiedTarget(); specificTarget != "" { if target, ok := workflow.Targets[specificTarget]; ok { + isPublished = target.IsPublished() if source, ok := workflow.Sources[target.Source]; ok && source.Registry != nil { sources = append(sources, target.Source) } @@ -206,6 +209,7 @@ func addCurrentBranchTagging(g *git.Git, latestRelease map[string]releases.Langu } if targetIsMatched { + isPublished = isPublished || target.IsPublished() if source, ok := workflow.Sources[target.Source]; ok && source.Registry != nil { sources = append(sources, target.Source) } @@ -219,7 +223,11 @@ func addCurrentBranchTagging(g *git.Git, latestRelease map[string]releases.Langu } if (len(sources) > 0 || len(targets) > 0) && branch != "" { - return cli.Tag([]string{branch}, sources, targets) + tags := []string{branch} + if isPublished { + tags = append(tags, "published") + } + return cli.Tag(tags, sources, targets) } return nil diff --git a/internal/actions/runWorkflow.go b/internal/actions/runWorkflow.go index 7146eab..06b7dca 100644 --- a/internal/actions/runWorkflow.go +++ b/internal/actions/runWorkflow.go @@ -304,9 +304,12 @@ func addDirectModeBranchTagging() error { branch := strings.TrimPrefix(os.Getenv("GITHUB_REF"), "refs/heads/") var sources, targets []string + // a tag that is applied if the target contributing is published + var isPublished bool // the tagging library treats targets synonymously with code samples if specificTarget := environment.SpecifiedTarget(); specificTarget != "" { if target, ok := wf.Targets[specificTarget]; ok { + isPublished = target.IsPublished() if source, ok := wf.Sources[target.Source]; ok && source.Registry != nil { sources = append(sources, target.Source) } @@ -317,6 +320,7 @@ func addDirectModeBranchTagging() error { } } else { for name, target := range wf.Targets { + isPublished = isPublished || target.IsPublished() if source, ok := wf.Sources[target.Source]; ok && source.Registry != nil { sources = append(sources, target.Source) } @@ -327,6 +331,10 @@ func addDirectModeBranchTagging() error { } } if (len(sources) > 0 || len(targets) > 0) && branch != "" { + tags := []string{branch} + if isPublished { + tags = append(tags, "published") + } return cli.Tag([]string{branch}, sources, targets) }