Debian package and publish changes
- Use parameters instead of env vars to create debian packages. - Target to publish the deb package to the debian repo.
This commit is contained in:
parent
ae041c8f61
commit
015bda2137
6 changed files with 134 additions and 276 deletions
|
@ -40,9 +40,14 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult GenerateDeb(BuildTargetContext c)
|
||||
{
|
||||
var env = PackageTargets.GetCommonEnvVars(c);
|
||||
Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-debian.sh"))
|
||||
.Environment(env)
|
||||
var channel = c.BuildContext.Get<string>("Channel").ToLower();
|
||||
var packageName = Monikers.GetDebianPackageName(c);
|
||||
var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
|
||||
var debFile = c.BuildContext.Get<string>("InstallerFile");
|
||||
var manPagesDir = Path.Combine(Dirs.RepoRoot, "Documentation", "manpages");
|
||||
|
||||
Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-debian.sh"),
|
||||
"-v", version, "-i", Dirs.Stage2, "-o", debFile, "-p", packageName, "-m", manPagesDir, "-c", channel)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
|
|
|
@ -102,6 +102,44 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target(nameof(PublishInstallerFile))]
|
||||
[BuildPlatforms(BuildPlatform.Ubuntu)]
|
||||
public static BuildTargetResult PublishDebFileToDebianRepo(BuildTargetContext c)
|
||||
{
|
||||
var packageName = Monikers.GetDebianPackageName(c);
|
||||
var installerFile = c.BuildContext.Get<string>("InstallerFile");
|
||||
var uploadUrl = $"https://dotnetcli.blob.core.windows.net/dotnet/{Channel}/Installers/{Version}/{Path.GetFileName(installerFile)}";
|
||||
var uploadJson = GenerateUploadJsonFile(packageName, Version, uploadUrl);
|
||||
|
||||
Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "publish", "repoapi_client.sh"), "-addpkg", uploadJson)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
private static string GenerateUploadJsonFile(string packageName, string version, string uploadUrl)
|
||||
{
|
||||
var repoID = Environment.GetEnvironmentVariable("REPO_ID");
|
||||
var uploadJson = Path.Combine(Dirs.Packages, "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\":\"{version}\",");
|
||||
sw.WriteLine($" \"repositoryId\":\"{repoID}\",");
|
||||
sw.WriteLine($" \"sourceUrl\":\"{uploadUrl}\"");
|
||||
sw.WriteLine("}");
|
||||
}
|
||||
}
|
||||
|
||||
return uploadJson;
|
||||
}
|
||||
|
||||
private static BuildTargetResult PublishFile(BuildTargetContext c, string file)
|
||||
{
|
||||
var env = PackageTargets.GetCommonEnvVars(c);
|
||||
|
|
|
@ -16,6 +16,29 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return $"dotnet-{osname}-{arch}.{version}";
|
||||
}
|
||||
|
||||
public static string GetDebianPackageName(BuildTargetContext c)
|
||||
{
|
||||
var channel = c.BuildContext.Get<string>("Channel").ToLower();
|
||||
var packageName = "";
|
||||
switch (channel)
|
||||
{
|
||||
case "dev":
|
||||
packageName = "dotnet-nightly";
|
||||
break;
|
||||
case "beta":
|
||||
case "rc1":
|
||||
case "rc2":
|
||||
case "rtm":
|
||||
packageName = "dotnet";
|
||||
break;
|
||||
default:
|
||||
throw new Exception($"Unknown channel - {channel}");
|
||||
break;
|
||||
}
|
||||
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public static string GetOSShortName()
|
||||
{
|
||||
string osname = "";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue