Refactor PublishTargets.cs, add publishing of all installers and archives to azure, change all versions to nuget versions.
This commit is contained in:
parent
7486b45eeb
commit
f596b8ddce
5 changed files with 339 additions and 143 deletions
54
scripts/dotnet-cli-build/Publishing/DebRepoPublisher.cs
Normal file
54
scripts/dotnet-cli-build/Publishing/DebRepoPublisher.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.WindowsAzure.Storage;
|
||||
using Microsoft.WindowsAzure.Storage.Blob;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class DebRepoPublisher
|
||||
{
|
||||
private string _repoID;
|
||||
private string _uploadJsonDirectory;
|
||||
|
||||
public DebRepoPublisher(string uploadJsonDirectory)
|
||||
{
|
||||
_uploadJsonDirectory = uploadJsonDirectory;
|
||||
_repoID = Environment.GetEnvironmentVariable("REPO_ID");
|
||||
}
|
||||
|
||||
public void PublishDebFileToDebianRepo(string packageName, string packageVersion, string uploadUrl)
|
||||
{
|
||||
var uploadJson = GenerateUploadJsonFile(packageName, packageVersion, uploadUrl);
|
||||
|
||||
Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "publish", "repoapi_client.sh"), "-addpkg", uploadJson)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
|
||||
private string GenerateUploadJsonFile(string packageName, string packageVersion, string uploadUrl)
|
||||
{
|
||||
var uploadJson = Path.Combine(_uploadJsonDirectory, "package_upload.json");
|
||||
File.Delete(uploadJson);
|
||||
|
||||
using (var fileStream = File.Create(uploadJson))
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(fileStream))
|
||||
{
|
||||
sw.WriteLine("{");
|
||||
sw.WriteLine($" \"name\":\"{packageName}\",");
|
||||
sw.WriteLine($" \"version\":\"{packageVersion}\",");
|
||||
sw.WriteLine($" \"repositoryId\":\"{_repoID}\",");
|
||||
sw.WriteLine($" \"sourceUrl\":\"{uploadUrl}\"");
|
||||
sw.WriteLine("}");
|
||||
}
|
||||
}
|
||||
|
||||
return uploadJson;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue