-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: registry tagging action (#136)
* feat: registry tagging action * fix: import cycle * Update internal/cli/speakeasy.go Co-authored-by: David Alberto Adler <dalberto.adler@gmail.com> * fix: tag command args --------- Co-authored-by: David Alberto Adler <dalberto.adler@gmail.com>
- Loading branch information
1 parent
77062f9
commit 2451b10
Showing
8 changed files
with
169 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Speakeasy Registry Tagger | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
sources: | ||
description: "The sources to tag (comma or newline separated)" | ||
required: false | ||
type: string | ||
code_samples: | ||
description: "The targets to tag code samples for (comma or newline separated)" | ||
required: false | ||
type: string | ||
registry_tags: | ||
description: "Multi-line or single-line string input of tags to apply to speakeasy registry builds" | ||
required: false | ||
type: string | ||
secrets: | ||
speakeasy_api_key: | ||
description: The API key to use to authenticate the Speakeasy CLI | ||
required: true | ||
jobs: | ||
run-workflow: | ||
name: Apply Tags in Speakeasy Registry | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Tune GitHub-hosted runner network | ||
uses: smorimoto/tune-github-hosted-runner-network@v1 | ||
- id: apply-tags | ||
name: Apply Tags | ||
uses: speakeasy-api/sdk-generation-action@v15 | ||
with: | ||
action: "tag" | ||
sources: ${{ inputs.sources }} | ||
code_samples: ${{ inputs.code_samples }} | ||
registry_tags: ${{ inputs.registry_tags }} | ||
speakeasy_api_key: ${{ secrets.speakeasy_api_key }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package actions | ||
|
||
import ( | ||
"github.com/speakeasy-api/sdk-generation-action/internal/cli" | ||
"github.com/speakeasy-api/sdk-generation-action/internal/configuration" | ||
"github.com/speakeasy-api/sdk-generation-action/internal/environment" | ||
"github.com/speakeasy-api/sdk-generation-action/internal/logging" | ||
"github.com/speakeasy-api/sdk-generation-action/internal/registry" | ||
"golang.org/x/exp/maps" | ||
) | ||
|
||
func Tag() error { | ||
g, err := initAction() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if _, err = cli.Download("latest", g); err != nil { | ||
return err | ||
} | ||
|
||
tags := registry.ProcessRegistryTags() | ||
|
||
sources := environment.SpecifiedSources() | ||
targets := environment.SpecifiedCodeSamplesTargets() | ||
|
||
if len(sources) == 0 && len(targets) == 0 { | ||
wf, err := configuration.GetWorkflowAndValidateLanguages(false) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
sources = maps.Keys(wf.Sources) | ||
targets = maps.Keys(wf.Targets) | ||
|
||
logging.Info("No sources or targets specified, using all sources and targets from workflow") | ||
} | ||
|
||
return cli.Tag(tags, sources, targets) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package registry | ||
|
||
import ( | ||
"github.com/speakeasy-api/sdk-generation-action/internal/environment" | ||
"strings" | ||
) | ||
|
||
func ProcessRegistryTags() []string { | ||
var tags []string | ||
tagsInput := environment.RegistryTags() | ||
if len(strings.Replace(tagsInput, " ", "", -1)) == 0 { | ||
return tags | ||
} | ||
|
||
var processedTags []string | ||
if strings.Contains(tagsInput, "\n") { | ||
processedTags = strings.Split(tagsInput, "\n") | ||
} else { | ||
processedTags = strings.Split(tagsInput, ",") | ||
} | ||
|
||
for _, tag := range processedTags { | ||
tag = strings.Replace(tag, " ", "", -1) | ||
if len(tag) > 0 { | ||
tags = append(tags, tag) | ||
} | ||
} | ||
|
||
return tags | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters