public static GitHubRelease GetLatestReleaseOnGitHub(SetupContext context, string apiUrl, string owner, string repo) { string url = $"{apiUrl}/repos/{owner}/{repo}/releases/latest"; string jsonSource = context.DownloadString("list of latest git releases", url); JObject json = JObject.Parse(jsonSource); GitHubRelease result = new GitHubRelease { IsPrerelease = json.Value <bool>("prerelease"), IsDraft = json.Value <bool>("draft"), }; foreach (JToken assetToken in json["assets"]) { GitHubReleaseAsset asset = new GitHubReleaseAsset { ID = assetToken.Value <long>("id"), RawContentType = assetToken.Value <string>("content_type"), RawState = assetToken.Value <string>("state"), SizeInBytes = assetToken.Value <long>("size"), BrowserDownloadUrl = assetToken.Value <string>("browser_download_url"), }; asset.ContentType = ParseGitHubContentTypeString(asset.RawContentType); asset.State = ParseGitHubReleaseStateString(asset.RawState); result.Assets.Add(asset); } return(result); }
public void Run(SetupContext context) { if (!context.IsChocolateyInstalled()) { string chocoInstallScript = context.DownloadString("Chocolatey install script URL", ChocoInstallScriptUrl); context.ExecutePowershell(chocoInstallScript); context.ExecuteChocolatey("feature", "enable", "-n=allowGlobalConfirmation"); } //string chocoSavePath = context.CreateSaveDir("chocolatey"); //string chocoPackagesFilePath = Path.Combine(chocoSavePath, "choco-packages.config"); //File.WriteAllText(chocoPackagesFilePath, Resources.choco_packages, Encoding.UTF8); //ExecuteChocolatey(context, ChocoExePath, "install", chocoPackagesFilePath); }