diff --git a/flytectl/cmd/register/register_util.go b/flytectl/cmd/register/register_util.go index 29e83c698d2..c94c990ee2c 100644 --- a/flytectl/cmd/register/register_util.go +++ b/flytectl/cmd/register/register_util.go @@ -561,20 +561,11 @@ func getAllExample(repository, version string) ([]*github.ReleaseAsset, *github. } return filterExampleFromRelease(release), release, nil } - releases, err := githubutil.GetListRelease(repository) + release, err := githubutil.GetLatestVersion(repository) if err != nil { return nil, nil, err } - if len(releases) == 0 { - return nil, nil, fmt.Errorf("repository doesn't have any release") - } - for _, v := range releases { - if !*v.Prerelease { - return filterExampleFromRelease(v), v, nil - } - } - return nil, nil, nil - + return filterExampleFromRelease(release), release, nil } func getRemoteStoragePath(ctx context.Context, s *storage.DataStore, remoteLocation, file, identifier string) (storage.DataReference, error) { diff --git a/flytectl/pkg/util/githubutil/githubutil.go b/flytectl/pkg/util/githubutil/githubutil.go index 075b1cc8df2..257eaad970b 100644 --- a/flytectl/pkg/util/githubutil/githubutil.go +++ b/flytectl/pkg/util/githubutil/githubutil.go @@ -65,7 +65,8 @@ func GetGHClient() *github.Client { return github.NewClient(&http.Client{}) } -// GetLatestVersion returns the latest version of provided repository +// GetLatestVersion returns the latest non-prerelease version of provided repository, as +// described in https://docs.github.com/en/rest/reference/releases#get-the-latest-release func GetLatestVersion(repository string) (*github.RepositoryRelease, error) { client := GetGHClient() release, _, err := client.Repositories.GetLatestRelease(context.Background(), owner, repository)