private async Task PushFile(string file, FeedzClient client) { if (!File.Exists(file)) { Log.Error("The file {file:l} does not exist", file); return; } try { var repo = client.ScopeToRepository(_org, _repo); Log.Information("Pushing {file:l} to {uri:l}", file, repo.Packages.FeedUri.AbsoluteUri); using (var fs = File.OpenRead(file)) await repo.Packages.Upload(fs, Path.GetFileName(file), _force); Log.Information("Pushed {file:l}", file); } catch (TaskCanceledException) { Log.Information("The push time limit was exceeded, specify the -timeout parameter to extend the timeout"); } catch (Exception ex) { Log.Error("Error pushing {file:l}: {message}", file, ex.Message); } }
public static FeedzClient Create(string pat, string region) { var useXyz = !string.IsNullOrEmpty(region) && region.StartsWith("xyz"); if (useXyz) region = region.Substring(3); return useXyz ? FeedzClient.Create(pat, "https://feedz.xyz/", "https://f.feedz.xyz/") : FeedzClient.Create(pat); }
private static async Task UploadPackagesAsync() { try { var client = FeedzClient.Create(_apiKey); RepositoryScope repositoryScope = client.ScopeToRepository(_organization, _repository); // Load *ALL* the New Packages var files = Directory.GetFiles(_path); var numberOfFiles = files.Count(); var counterFiles = 1; Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine($"{numberOfFiles} (*.nupkg) file(s) found!"); Console.WriteLine(); foreach (var file in files) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine($"[{counterFiles}] Uploading {file}..."); try { await repositoryScope.PackageFeed.Upload(file); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"{file} correctly uploaded!"); Console.WriteLine(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); if (ex.Message == "Forbidden") { Console.WriteLine("Please, check the API Key to access and write into your own repo"); } Console.WriteLine(); Console.ResetColor(); } counterFiles += 1; } Console.ResetColor(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("An error ocurred!"); Console.WriteLine(ex.Message); Console.WriteLine(); Console.ResetColor(); } }