Exemple #1
0
        public static async Task <Repository> GetRepoFromGitHub(ModUpdateInfo info, string repoName,
                                                                string repoAuthor = "")
        {
            if (repoName != "" && repoAuthor != "")
            {
                return(info.Client.Repository.Get(repoAuthor, repoName).Result);
            }

            var request = new SearchRepositoriesRequest(repoName)
            {
                Language = Language.CSharp,
                Archived = false
            };

            var searchResult = await info.Client.Search.SearchRepo(request);

            Repository repository = null;

            if (searchResult?.Items?.Count > 0)
            {
                repository = searchResult.Items.First();
            }

            return(repository);
        }
Exemple #2
0
 private static void PatreonPostRequest(ReleaseSettings settings, ModUpdateInfo updateInfo)
 {
     if (UserAccepts("Update Patreon post now? (Y/N): "))
     {
         PatreonUtility.UpdatePost(settings, updateInfo);
     }
 }
Exemple #3
0
        public static async Task <Release> CreateRelease(ModUpdateInfo info, Repository repo, string version,
                                                         string name, string body)
        {
            //Get list of commits
            var latestCommits = Task.Run(async() =>
                                         await info.Client.Repository.Commit.GetAll(repo.Owner.Login, repo.Name));

            latestCommits.Wait();
            var latestCommit = latestCommits.Result.First().Sha;

            //Check if release exists for the version #
            var curVersion = version;

            for (int newVersionAdditive = 0; newVersionAdditive < 999; newVersionAdditive++)
            {
                Console.WriteLine("Checking if release tag for version number already exists...");
                var versCheck = Task.Run(async() => await info.Client.Repository.Release.GetAll(repo.Id));
                versCheck.Wait();
                if (versCheck.Result.Any(x => x.TagName == curVersion))
                {
                    curVersion = curVersion + newVersionAdditive;
                    Console.WriteLine("Release tag exists. Setting new version to " + curVersion);
                }
                else
                {
                    Console.WriteLine("Final release tag set as " + curVersion);
                    break;
                }
            }
            //Set a tag for our release
            var tag = new NewTag
            {
                Message = name + " - " + body,
                Tag     = curVersion,
                Object  = latestCommit,      // short SHA
                Type    = TaggedType.Commit, // TODO: what are the defaults when nothing specified?
                Tagger  = new Committer(info.GitHubAuthor, info.GitHubEmail, DateTimeOffset.UtcNow)
            };
            var newTagProc = Task.Run(async() => await info.Client.Git.Tag.Create(repo.Owner.Login, repo.Name, tag));

            newTagProc.Wait();

            var newTag = newTagProc.Result;

            Console.WriteLine("Created a tag for {0} at {1}", newTag.Tag, newTag.Sha);

            var newRelease = new NewRelease(newTag.Tag)
            {
                Name       = repo.Name + " " + name,
                Body       = body,
                Draft      = false,
                Prerelease = false
            };


            var result = await info.Client.Repository.Release.Create(repo.Owner.Login, repo.Name, newRelease);

            return(result);
        }
Exemple #4
0
        public static Repository GetGithubRepository(ModUpdateInfo info, ReleaseSettings settings, string repoName,
                                                     string repoAuthor = "")
        {
            var task = Task.Run(async() => await GetRepoFromGitHub(info, repoName, repoAuthor));

            task.Wait(TimeSpan.FromSeconds(30));
            return(task.Result);
        }
Exemple #5
0
        public static void Main(string[] args)
        {
            InitializeProgram();
            ReleaseSettings settings;

            InitializeSettings(out settings);

            var workspacePath = ResolvePathForWorkspace(args);
            var releasePath   = ResolvePathForRelease(args);
            var curDirName    = workspacePath.Split(Path.DirectorySeparatorChar).Last();

            ////////////////////////////////////////
            /// Automating the RimWorld Dev Process
            ////////////////////////////////////////

            //////////////////////////////
            /// Testing or Releasing
            //1. Make seperate directory for release.
            if (!DeleteExistingDirectoriesIfAny(releasePath, workspacePath))
            {
                goto Abort;
            }
            CopyFilesAndDirectories(workspacePath, settings.FilteredWhenCopied.ClearWhiteSpace().Split(','),
                                    releasePath);
            //2. Restart RimWorld for testing.
            RestartRimWorldRequest();

            if (!UserAccepts("\nPublish update for " + curDirName + "? (Y/N) :"))
            {
                goto Abort;
            }
            var updateInfo = new ModUpdateInfo(settings, workspacePath, releasePath);

            /////////////////////////////
            /// Publishing
            //1. Update GitHub
            GitHubCommitAndReleaseRequest(settings, updateInfo);
            //2. Update Patreon
            //PatreonPostRequest(settings, updateInfo); //TODO
            ZipFilesRequest(releasePath, updateInfo, settings.FilteredWhenZipped.ClearWhiteSpace().Split(','));
            //3. Update Ludeon
            //LudeonPostRequest(settings, updateInfo); //TODO
            //4. Update Steam
            SteamUpdateRequest(settings, updateInfo, releasePath, workspacePath); //TODO
            //5. Update Discord
            SendJSONToDiscordWebhook(settings, updateInfo);
            //6. Print reports
            OutputUpdateReport(settings, updateInfo);

Abort:
            Console.WriteLine("\nFin."); // Any key to exit...");
        }
Exemple #6
0
 private static void SteamUpdateRequest(ModUpdateInfo updateInfo, string modRootPath)
 {
     try
     {
         var mod = new Mod(modRootPath);
         SteamUtility.Init();
         Console.WriteLine(mod.ToString());
         Console.WriteLine($"Latest changenote: {updateInfo.LatestChangeNote}");
         if (SteamUtility.Upload(mod, updateInfo.LatestChangeNote))
         {
             Console.WriteLine("Upload done");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     finally
     {
         SteamUtility.Shutdown();
     }
 }
Exemple #7
0
        public static void Main(string[] args)
        {
            InitializeProgram();
            if (args.Length != 1)
            {
                Console.WriteLine("You must specify one parameter, the base path to the mod-folder.");
                return;
            }

            var modFolderPath = args[0];

            if (!Directory.Exists(modFolderPath))
            {
                Console.WriteLine($"{modFolderPath} not found");
                return;
            }


            var updateInfo = new ModUpdateInfo(modFolderPath);

            SteamUpdateRequest(updateInfo, modFolderPath);
        }
Exemple #8
0
        private static void SteamUpdateRequest(ReleaseSettings settings, ModUpdateInfo updateInfo, string releasePath, string workspacePath)
        {
            if (UserAccepts("Upload to Steam workshop now? (Y/N): "))
            {
                try
                {
                    var publishedIdPath    = releasePath + @"\About\PublishedFileId.txt";
                    var publishedIdPathTwo = workspacePath + @"\About\PublishedFileId.txt";
                    if (!File.Exists(publishedIdPath))
                    {
                        if (UserAccepts("\nPublishedFileId.txt not detected. Input workshop ID now? (Y / N): "))
                        {
                            Console.WriteLine("\nPlease enter the workshop ID OR Press ENTER to continue: ");
                            var newPublishedId = Console.ReadLine();
                            using (var sw = File.CreateText(publishedIdPath))
                            {
                                sw.WriteLine(newPublishedId);
                            }
                            using (var sw = File.CreateText(publishedIdPathTwo))
                            {
                                sw.WriteLine(newPublishedId);
                            }
                        }
                    }

                    var mod = new Mod(releasePath);
                    SteamUtility.Init();
                    Console.WriteLine(mod.ToString());
                    if (SteamUtility.Upload(mod, UpdateReport(updateInfo)))
                    {
                        Console.WriteLine("Upload done");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
Exemple #9
0
 public static void UpdatePost(ReleaseSettings settings, ModUpdateInfo updateInfo)
 {
     throw new NotImplementedException();
 }