Skip to content

Commit

Permalink
feat: propogate CLI/Generation version from what was used by the CLI (#…
Browse files Browse the repository at this point in the history
…172)

* feat: propogate CLI/Generation version from what was used by the CLI

* feat: propogate CLI/Generation version from what was used by the CLI
  • Loading branch information
ryan-timothy-albert authored Oct 9, 2024
1 parent 97a2ff0 commit 6fd34c3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow-executor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
required: false
type: string
speakeasy_version:
description: The version of the Speakeasy CLI to use or "latest"
description: The version of the Speakeasy CLI to use or "latest" [DEPRECATED]
default: latest
required: false
type: string
Expand Down
10 changes: 6 additions & 4 deletions internal/actions/runWorkflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func RunWorkflow() error {
return err
}

// This flag is generally deprecated, it will not be provided on new action instances
pinnedVersion := cli.GetVersion(environment.GetPinnedSpeakeasyVersion())
if pinnedVersion != "latest" {
resolvedVersion = pinnedVersion
Expand Down Expand Up @@ -98,19 +99,18 @@ func RunWorkflow() error {
}
return err
}
outputs["resolved_speakeasy_version"] = resolvedVersion

anythingRegenerated := false

var releaseInfo releases.ReleasesInfo
if runRes.GenInfo != nil {
docVersion := runRes.GenInfo.OpenAPIDocVersion
speakeasyVersion := runRes.GenInfo.SpeakeasyVersion
resolvedVersion = runRes.GenInfo.SpeakeasyVersion

releaseInfo = releases.ReleasesInfo{
ReleaseTitle: environment.GetInvokeTime().Format("2006-01-02 15:04:05"),
DocVersion: docVersion,
SpeakeasyVersion: speakeasyVersion,
SpeakeasyVersion: resolvedVersion,
GenerationVersion: runRes.GenInfo.GenerationVersion,
DocLocation: environment.GetOpenAPIDocLocation(),
Languages: map[string]releases.LanguageReleaseInfo{},
Expand Down Expand Up @@ -156,11 +156,13 @@ func RunWorkflow() error {
return err
}

if _, err := g.CommitAndPush(docVersion, speakeasyVersion, "", environment.ActionRunWorkflow, false); err != nil {
if _, err := g.CommitAndPush(docVersion, resolvedVersion, "", environment.ActionRunWorkflow, false); err != nil {
return err
}
}

outputs["resolved_speakeasy_version"] = resolvedVersion

if sourcesOnly {
if _, err := g.CommitAndPush("", resolvedVersion, "", environment.ActionRunWorkflow, sourcesOnly); err != nil {
return err
Expand Down
18 changes: 14 additions & 4 deletions internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ func Run(g Git, pr *github.PullRequest, wf *workflow.Workflow) (*RunResult, map[
workspace := environment.GetWorkspace()
outputs := map[string]string{}

speakeasyVersion, err := cli.GetSpeakeasyVersion()
executeSpeakeasyVersion, err := cli.GetSpeakeasyVersion()
if err != nil {
return nil, outputs, fmt.Errorf("failed to get speakeasy version: %w", err)
}
generationVersion, err := cli.GetGenerationVersion()
executeGenerationVersion, err := cli.GetGenerationVersion()
if err != nil {
return nil, outputs, fmt.Errorf("failed to get generation version: %w", err)
}
speakeasyVersion := executeSpeakeasyVersion.String()
generationVersion := executeGenerationVersion.String()

langGenerated := map[string]bool{}

Expand Down Expand Up @@ -186,6 +188,14 @@ func Run(g Git, pr *github.PullRequest, wf *workflow.Workflow) (*RunResult, map[

if dirty {
langGenerated[lang] = true
// Set speakeasy version and generation version to what was used by the CLI
if currentManagementInfo.SpeakeasyVersion != "" {
speakeasyVersion = currentManagementInfo.SpeakeasyVersion
}
if currentManagementInfo.GenerationVersion != "" {
generationVersion = currentManagementInfo.GenerationVersion
}

fmt.Printf("Regenerating %s SDK resulted in significant changes %s\n", lang, dirtyMsg)
} else {
fmt.Printf("Regenerating %s SDK did not result in any changes\n", lang)
Expand Down Expand Up @@ -215,8 +225,8 @@ func Run(g Git, pr *github.PullRequest, wf *workflow.Workflow) (*RunResult, map[

if regenerated {
genInfo = &GenerationInfo{
SpeakeasyVersion: speakeasyVersion.String(),
GenerationVersion: generationVersion.String(),
SpeakeasyVersion: speakeasyVersion,
GenerationVersion: generationVersion,
// OpenAPIDocVersion: docVersion, //TODO
Languages: langGenInfo,
}
Expand Down

0 comments on commit 6fd34c3

Please sign in to comment.