protected override IEnumerator DistributeCoroutine(IEnumerable <BuildPath> buildPaths, bool forceBuild) { // Check Pipeline Builder Executable var cmd = FindPipelineBuilder(); if (cmd == null) { yield return(false); yield break; } // Check User if (string.IsNullOrEmpty(gogLogin.User)) { Debug.LogError("GOGDistro: No GOG user set."); yield return(false); yield break; } if (gogLogin.GetPassword(keychainService) == null) { Debug.LogError("GOGDistro: No GOG password found in Keychain."); yield return(false); yield break; } // Check projects if (string.IsNullOrEmpty(projectsFolder) || !Directory.Exists(projectsFolder)) { Debug.LogError("GOGDistro: Path to projects folder not set."); yield return(false); yield break; } // Check ignore list if (!string.IsNullOrEmpty(ignoreList) && !File.Exists(ignoreList)) { Debug.LogError("GOGDistro: Ignore list could not be found: " + ignoreList); yield return(false); yield break; } // Process projects var tempDir = FileUtil.GetUniqueTempPathInProject(); Directory.CreateDirectory(tempDir); var targets = new HashSet <BuildTarget>(buildPaths.Select(p => p.target)); var projects = new List <string>(); var convertError = false; foreach (var file in Directory.GetFiles(projectsFolder)) { if (Path.GetExtension(file).ToLower() != ".json") { continue; } var contents = PathVarRegex.Replace(File.ReadAllText(file), (match) => { var platformName = match.Groups[1].Value.ToLower(); if (platformName == "project") { return(Path.GetDirectoryName(Application.dataPath)); } else if (platformName == "projects") { return(Path.GetFullPath(projectsFolder)); } BuildTarget target; try { target = (BuildTarget)System.Enum.Parse(typeof(BuildTarget), platformName, true); } catch { Debug.LogError("GOGDistro: Invalid build target path variable '" + platformName + "' in project JSON:" + file); convertError = true; return(""); } if (!buildPaths.Any(p => p.target == target)) { Debug.LogError("GOGDistro: Build target '" + platformName + "' not part of given build profile(s) in project JSON:" + file); convertError = true; return(""); } targets.Remove(target); var path = buildPaths.Where(p => p.target == target).Select(p => p.path).First(); path = OptionHelper.GetBuildBasePath(path); return(Path.GetFullPath(path)); }); if (convertError) { break; } var targetPath = Path.Combine(tempDir, Path.GetFileName(file)); File.WriteAllText(targetPath, contents); projects.Add(targetPath); } if (convertError) { yield return(false); yield break; } if (targets.Count > 0) { Debug.LogWarning("GOGDistro: Not all build targets filled into variables. Left over: " + string.Join(", ", targets.Select(t => t.ToString()).ToArray())); } // Notarize mac builds if (macNotarization != null) { foreach (var path in buildPaths.Where(p => p.target == BuildTarget.StandaloneOSX)) { yield return(macNotarization.Notarize(path)); if (GetSubroutineResult <string>() == null) { yield return(false); yield break; } } } // Build foreach (var project in projects) { var args = string.Format( "build-game '{0}' --username='******' --password='******' --version={3}", Path.GetFullPath(project), gogLogin.User, gogLogin.GetPassword(keychainService), string.IsNullOrEmpty(overrideVersion) ? Application.version : overrideVersion ); if (!string.IsNullOrEmpty(ignoreList)) { args += $" --ignore_list='{Path.GetFullPath(ignoreList)}'"; } if (!string.IsNullOrEmpty(branch.User)) { args += $" --branch='{branch.User}'"; var pwd = branch.GetPassword(branchKeychainService); if (pwd != null) { args += $" --branch_password='******'"; } } yield return(Execute(cmd, args)); } Directory.Delete(tempDir, true); yield return(true); }
protected override IEnumerator DistributeCoroutine(IEnumerable <BuildPath> buildPaths, bool forceBuild) { // Check SDK var cmd = FindSteamCmd(); if (cmd == null) { yield return(false); yield break; } // Check User if (string.IsNullOrEmpty(steamLogin.User)) { Debug.LogError("SteamDistro: No Steam user set."); yield return(false); yield break; } if (steamLogin.GetPassword(keychainService) == null) { Debug.LogError("SteamDistro: No Steam password found in Keychain."); yield return(false); yield break; } // Check scripts if (string.IsNullOrEmpty(scriptsFolder) || !Directory.Exists(scriptsFolder)) { Debug.LogError("SteamDistro: Path to scripts folder not set."); yield return(false); yield break; } if (string.IsNullOrEmpty(appScript)) { Debug.LogError("SteamDistro: Name of app script not set."); yield return(false); yield break; } var appScriptPath = Path.Combine(scriptsFolder, appScript); if (!File.Exists(appScriptPath)) { Debug.LogError("SteamDistro: App script not found in scripts folder."); yield return(false); yield break; } // Process scripts var tempDir = FileUtil.GetUniqueTempPathInProject(); Directory.CreateDirectory(tempDir); var targets = new HashSet <BuildTarget>(buildPaths.Select(p => p.target)); var convertError = false; foreach (var file in Directory.GetFiles(scriptsFolder)) { if (Path.GetExtension(file).ToLower() != ".vdf") { continue; } var contents = PathVarRegex.Replace(File.ReadAllText(file), (match) => { var platformName = match.Groups[1].Value.ToLower(); if (platformName == "project") { return(Path.GetDirectoryName(Application.dataPath)); } else if (platformName == "scripts") { return(Path.GetFullPath(scriptsFolder)); } BuildTarget target; try { target = (BuildTarget)System.Enum.Parse(typeof(BuildTarget), platformName, true); } catch { Debug.LogError("SteamDistro: Invalid build target path variable '" + platformName + "' in VDF script:" + file); convertError = true; return(""); } if (!buildPaths.Any(p => p.target == target)) { Debug.LogError("SteamDistro: Build target '" + platformName + "' not part of given build profile(s) in VDF script:" + file); convertError = true; return(""); } targets.Remove(target); var path = buildPaths.Where(p => p.target == target).Select(p => p.path).First(); path = OptionHelper.GetBuildBasePath(path); return(Path.GetFullPath(path)); }); if (convertError) { break; } var targetPath = Path.Combine(tempDir, Path.GetFileName(file)); File.WriteAllText(targetPath, contents); } if (convertError) { yield return(false); yield break; } if (targets.Count > 0) { Debug.LogWarning("SteamDistro: Not all build targets filled into variables. Left over: " + string.Join(", ", targets.Select(t => t.ToString()).ToArray())); } // Notarize mac builds if (macNotarization != null) { foreach (var path in buildPaths.Where(p => p.target == BuildTarget.StandaloneOSX)) { yield return(macNotarization.Notarize(path)); if (GetSubroutineResult <string>() == null) { yield return(false); yield break; } } } // Build var scriptPath = Path.GetFullPath(Path.Combine(tempDir, appScript)); var args = string.Format( "+login '{0}' '{1}' +run_app_build_http '{2}' +quit", steamLogin.User, steamLogin.GetPassword(keychainService), scriptPath ); yield return(Execute(cmd, args, null, (output) => { if (output.Contains("Logged in OK")) { Debug.Log("SteamDistro: Logged in"); } else if (output.Contains("Building depot")) { var match = BuildingDepotRegex.Match(output); if (match.Success) { Debug.Log("SteamDistro: Building depo " + match.Groups[1].Value); } } else if (output.Contains("")) { var match = SuccessBuildIdRegex.Match(output); if (match.Success) { Debug.Log("SteamDistro: Build uploaded, ID = " + match.Groups[1].Value); } } })); Directory.Delete(tempDir, true); yield return(true); }
protected override async Task RunDistribute(IEnumerable <BuildPath> buildPaths, TaskToken task) { // Check Pipeline Builder Executable var cmd = FindPipelineBuilder(); // Check User if (string.IsNullOrEmpty(gogLogin.User)) { throw new Exception("GOGDistro: No GOG user set."); } if (gogLogin.GetPassword(keychainService) == null) { throw new Exception("GOGDistro: No GOG password found in Keychain."); } // Check projects if (string.IsNullOrEmpty(projectsFolder) || !Directory.Exists(projectsFolder)) { throw new Exception("GOGDistro: Path to projects folder not set."); } // Check ignore list if (!string.IsNullOrEmpty(ignoreList) && !File.Exists(ignoreList)) { throw new Exception("GOGDistro: Ignore list could not be found: " + ignoreList); } // Process projects var tempDir = FileUtil.GetUniqueTempPathInProject(); try { Directory.CreateDirectory(tempDir); var targets = new HashSet <BuildTarget>(buildPaths.Select(p => p.target)); var projects = new List <string>(); string convertError = null; foreach (var file in Directory.GetFiles(projectsFolder)) { if (Path.GetExtension(file).ToLower() != ".json") { continue; } var contents = PathVarRegex.Replace(File.ReadAllText(file), (match) => { var platformName = match.Groups[1].Value.ToLower(); if (platformName == "project") { return(Path.GetDirectoryName(Application.dataPath)); } else if (platformName == "projects") { return(Path.GetFullPath(projectsFolder)); } BuildTarget target; try { target = (BuildTarget)System.Enum.Parse(typeof(BuildTarget), platformName, true); } catch { convertError = $"Invalid build target path variable '{platformName}' in project JSON: {file}"; return(""); } if (!buildPaths.Any(p => p.target == target)) { convertError = $"Build target '{platformName}' not part of given build profile(s) in project JSON: {file}"; return(""); } targets.Remove(target); var path = buildPaths.Where(p => p.target == target).Select(p => p.path).First(); path = OptionHelper.GetBuildBasePath(path); return(Path.GetFullPath(path)); }); if (convertError != null) { break; } var targetPath = Path.Combine(tempDir, Path.GetFileName(file)); File.WriteAllText(targetPath, contents); projects.Add(targetPath); } if (convertError != null) { throw new Exception($"GOGDistro: {convertError}"); } if (targets.Count > 0) { Debug.LogWarning("GOGDistro: Not all build targets filled into variables. Left over: " + string.Join(", ", targets.Select(t => t.ToString()).ToArray())); } task.Report(0, targets.Count + 1); // Notarize mac builds if (macNotarization != null) { task.Report(0, description: "Notarizing macOS builds"); foreach (var path in buildPaths.Where(p => p.target == BuildTarget.StandaloneOSX)) { await macNotarization.Notarize(path, task); } } // Build task.baseStep++; foreach (var project in projects) { var args = string.Format( "build-game '{0}' --username='******' --password='******' --version={3}", Path.GetFullPath(project), gogLogin.User, gogLogin.GetPassword(keychainService), string.IsNullOrEmpty(overrideVersion) ? Application.version : overrideVersion ); if (!string.IsNullOrEmpty(ignoreList)) { args += $" --ignore_list='{Path.GetFullPath(ignoreList)}'"; } if (!string.IsNullOrEmpty(branch.User)) { args += $" --branch='{branch.User}'"; var pwd = branch.GetPassword(branchKeychainService); if (pwd != null) { args += $" --branch_password='******'"; } } task.Report(0, description: $"Uploading {Path.GetFileName(project)}"); await Execute(new ExecutionArgs(cmd, args), task); task.baseStep++; } } finally { // Always clean up temporary files Directory.Delete(tempDir, true); } }