public void PublishNewVersion(ModuleManifest manifest)
        {
            var version = ExternalModuleManifestVersion.FromManifest(manifest);

            Versions.Add(version);
            var byPlatformMajorGroups = Versions.GroupBy(x => x.PlatformSemanticVersion.Major).OrderByDescending(x => x.Key).ToList();

            Versions.Clear();
            foreach (var byPlatformGroup in byPlatformMajorGroups)
            {
                var latestReleaseVersion = byPlatformGroup.Where(x => string.IsNullOrEmpty(x.VersionTag))
                                           .OrderByDescending(x => x.SemanticVersion).FirstOrDefault();
                if (latestReleaseVersion != null)
                {
                    Versions.Add(latestReleaseVersion);
                }

                var latestPreReleaseVersion = byPlatformGroup.Where(x => !string.IsNullOrEmpty(x.VersionTag))
                                              .OrderByDescending(x => x.SemanticVersion)
                                              .ThenByDescending(x => x.VersionTag).FirstOrDefault();

                var addPreRelease = latestPreReleaseVersion != null;
                if (addPreRelease)
                {
                    addPreRelease = latestReleaseVersion == null || (!latestPreReleaseVersion.SemanticVersion.Equals(latestReleaseVersion.SemanticVersion) &&
                                                                     latestReleaseVersion.SemanticVersion.IsCompatibleWithBySemVer(latestPreReleaseVersion.SemanticVersion));
                }
                if (addPreRelease)
                {
                    Versions.Add(latestPreReleaseVersion);
                }
            }
        }
        public static ExternalModuleManifest FromManifest(ModuleManifest manifest)
        {
            var result = new ExternalModuleManifest
            {
                Title       = manifest.Title,
                Description = manifest.Description,
                Authors     = manifest.Authors,
                Copyright   = manifest.Copyright,
                Groups      = manifest.Groups,
                IconUrl     = manifest.IconUrl,
                Id          = manifest.Id,
                LicenseUrl  = manifest.LicenseUrl,
                Owners      = manifest.Owners,
                ProjectUrl  = manifest.ProjectUrl,
                RequireLicenseAcceptance = manifest.RequireLicenseAcceptance,
                Tags = manifest.Tags
            };

            result.Versions.Add(ExternalModuleManifestVersion.FromManifest(manifest));
            return(result);
        }