示例#1
0
        private static void uploadBuild(string version)
        {
            if (!canGitHub || string.IsNullOrEmpty(CodeSigningCertificate))
            {
                return;
            }

            write("Publishing to GitHub...");

            var req = new JsonWebRequest <GitHubRelease>($"{GitHubApiEndpoint}")
            {
                Method = HttpMethod.Post,
            };

            GitHubRelease targetRelease = getLastGithubRelease();

            if (targetRelease == null || targetRelease.TagName != version)
            {
                write($"- Creating release {version}...", ConsoleColor.Yellow);
                req.AddRaw(JsonConvert.SerializeObject(new GitHubRelease
                {
                    Name  = version,
                    Draft = true,
                }));
                req.AuthenticatedBlockingPerform();

                targetRelease = req.ResponseObject;
            }
            else
            {
                write($"- Adding to existing release {version}...", ConsoleColor.Yellow);
            }

            var assetUploadUrl = targetRelease.UploadUrl.Replace("{?name,label}", "?name={0}");

            foreach (var a in Directory.GetFiles(releases_folder).Reverse()) //reverse to upload RELEASES first.
            {
                if (Path.GetFileName(a).StartsWith('.'))
                {
                    continue;
                }

                write($"- Adding asset {a}...", ConsoleColor.Yellow);
                var upload = new WebRequest(assetUploadUrl, Path.GetFileName(a))
                {
                    Method      = HttpMethod.Post,
                    Timeout     = 240000,
                    ContentType = "application/octet-stream",
                };

                upload.AddRaw(File.ReadAllBytes(a));
                upload.AuthenticatedBlockingPerform();
            }

            openGitHubReleasePage();
        }
示例#2
0
        private static void uploadBuild(string version)
        {
            if (string.IsNullOrEmpty(GitHubAccessToken) || string.IsNullOrEmpty(codeSigningCertPath))
            {
                return;
            }

            write("Publishing to GitHub...");

            write($"- Creating release {version}...", ConsoleColor.Yellow);
            var req = new JsonWebRequest <GitHubRelease>($"{GitHubApiEndpoint}")
            {
                Method = HttpMethod.POST,
            };

            req.AddRaw(JsonConvert.SerializeObject(new GitHubRelease
            {
                Name       = version,
                Draft      = true,
                PreRelease = true
            }));
            req.AuthenticatedBlockingPerform();

            var assetUploadUrl = req.ResponseObject.UploadUrl.Replace("{?name,label}", "?name={0}");

            foreach (var a in Directory.GetFiles(ReleasesFolder).Reverse()) //reverse to upload RELEASES first.
            {
                write($"- Adding asset {a}...", ConsoleColor.Yellow);
                var upload = new WebRequest(assetUploadUrl, Path.GetFileName(a))
                {
                    Method      = HttpMethod.POST,
                    Timeout     = 240000,
                    ContentType = "application/octet-stream",
                };

                upload.AddRaw(File.ReadAllBytes(a));
                upload.AuthenticatedBlockingPerform();
            }

            openGitHubReleasePage();
        }
示例#3
0
文件: Program.cs 项目: tuita520/GDNET
        private static void UploadBuild(string version)
        {
            if (!CanGitHub)
            {
                return;
            }

            Write("Publishing to GitHub...");

            var req = new JsonWebRequest <GitHubRelease>($"{GitHubApiEndpoint}releases")
            {
                Method = HttpMethod.Post,
            };

            GitHubRelease targetRelease = GetLastGithubRelease();

            if (targetRelease == null || targetRelease.TagName != version)
            {
                Write($"- Creating release {version}...", ConsoleColor.Yellow);

                // Get all of the previous PR's name
                string body     = $"Version {version} for {GitHubRepoName} has been released! this now fixes and adds:\r\n";
                var    requests = GetPullRequests();

                // Adds every pull requests after the last release
                requests.ForEach(pr => { body += $"- {pr.Title} | [{pr.User.Name}]({pr.User.Link})\r\n"; });

                req.AddRaw(JsonConvert.SerializeObject(new GitHubRelease
                {
                    Name        = $"{GitHubRepoName} v{version}",
                    TagName     = version,
                    Description = body,
                    Draft       = true,
                    PublishedAt = DateTime.Now
                }));

                req.AuthenticatedBlockingPerform();

                targetRelease = req.ResponseObject;
            }
            else
            {
                Write($"- Adding to existing release {version}...", ConsoleColor.Yellow);
            }

            var assetUploadUrl = targetRelease.UploadUrl.Replace("{?name,label}", "?name={0}");

            foreach (var a in Directory.GetFiles(staging_folder).Reverse())
            {
                if (Path.GetFileName(a).StartsWith('.'))
                {
                    continue;
                }

                if (!Path.GetFileName(a).EndsWith(".nupkg"))
                {
                    continue;
                }

                var upload = new WebRequest(assetUploadUrl, Path.GetFileName(a))
                {
                    Method      = HttpMethod.Post,
                    Timeout     = 240000,
                    ContentType = "application/octet-stream",
                };

                upload.AddRaw(File.ReadAllBytes(a));
                upload.AuthenticatedBlockingPerform();
            }

            OpenGitHubReleasePage();
        }