-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automate selection of latest SDK versions (#530)
* first attempt * Add override capability * remove v from version string * add latest-sdk-version command to features tool * fix GH actions output * GITHUB_OUTPUT, not GITHUB_ENV * silly, missed .outputs * bump version to 1.3 in dotnet.csproj * PR comments * try to update the typescript code * bump version * run prettier * use anonymous struct * forgot to remove unused struct def * clean up code * move script to new file * forgot to rename file reference * Revert "forgot to rename file reference" This reverts commit c9c8e01. * Revert "move script to new file" This reverts commit 1e1dba2. * remove stale comment
- Loading branch information
Showing
12 changed files
with
627 additions
and
502 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
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 |
---|---|---|
|
@@ -30,6 +30,7 @@ func NewApp() *cli.App { | |
runCmd(), | ||
buildImageCmd(), | ||
publishImageCmd(), | ||
latestSdkVersionCmd(), | ||
}, | ||
} | ||
} |
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,65 @@ | ||
package cmd | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func latestSdkVersionCmd() *cli.Command { | ||
var config LatestSdkVersionConfig | ||
return &cli.Command{ | ||
Name: "latest-sdk-version", | ||
Usage: "get the latest SDK version", | ||
Flags: config.flags(), | ||
Action: func(ctx *cli.Context) error { | ||
return getLatestSdkVersion(config) | ||
}, | ||
} | ||
} | ||
|
||
type LatestSdkVersionConfig struct { | ||
Lang string | ||
} | ||
|
||
func (p *LatestSdkVersionConfig) flags() []cli.Flag { | ||
return []cli.Flag{ | ||
langFlag(&p.Lang), | ||
} | ||
} | ||
|
||
func getLatestSdkVersion(config LatestSdkVersionConfig) error { | ||
var sdk string | ||
sdk, err := expandLangName(config.Lang) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
url := fmt.Sprintf("https://api.github.com/repos/temporalio/sdk-%s/releases/latest", sdk) | ||
resp, err := http.Get(url) | ||
if err != nil { | ||
return fmt.Errorf("failed to query the GH API for SDK version: %w", err) | ||
} | ||
|
||
defer resp.Body.Close() | ||
body, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
return fmt.Errorf("failed to read body of GitHub Get request: %w", err) | ||
} | ||
|
||
var version struct { | ||
TagName string `json:"tag_name"` | ||
} | ||
err = json.Unmarshal(body, &version) | ||
if err != nil { | ||
return fmt.Errorf("failed to decode json response: %w", err) | ||
} | ||
|
||
fmt.Println(strings.TrimPrefix(version.TagName, "v")) | ||
|
||
return nil | ||
} |
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
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
Oops, something went wrong.