-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dotnet-after-1.3.0
- Loading branch information
Showing
12 changed files
with
645 additions
and
513 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.