Lets build a preview nuget when we build nugets

This commit is contained in:
Matthew Leibowitz 2018-02-22 19:56:48 +02:00
Родитель 062385eab5
Коммит abf9de57d9
5 изменённых файлов: 56 добавлений и 36 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -6,6 +6,7 @@ output/
tools/
*.VC.db
**/Resources/Resource.designer.cs
nuget/*.prerelease.nuspec
# User-specific files
*.suo

Просмотреть файл

@ -214,7 +214,7 @@ Task ("tests")
.IsDependentOn ("nuget")
.Does (() =>
{
ClearSkiaSharpNuGetCache ();
ClearSkiaSharpNuGetCache (VERSION_PACKAGES.Keys.ToArray ());
RunNuGetRestore ("./tests/SkiaSharp.Desktop.Tests/SkiaSharp.Desktop.Tests.sln");
@ -264,10 +264,10 @@ Task ("samples")
.Does (() =>
{
// clear the NuGets so we can use the build output
ClearSkiaSharpNuGetCache ();
ClearSkiaSharpNuGetCache (VERSION_PACKAGES.Keys.ToArray ());
// create the samples archive
CreateSamplesZip ("./samples/", "./output/");
CreateSamplesZip ("./samples/", "./output/", VERSION_PACKAGES);
var isLinux = IsRunningOnLinux ();
var isMac = IsRunningOnMac ();
@ -499,37 +499,37 @@ Task ("update-docs")
////////////////////////////////////////////////////////////////////////////////////////////////////
Task ("nuget")
.IsDependentOn ("set-versions")
.IsDependentOn ("libs")
.IsDependentOn ("docs")
.Does (() =>
{
// we can only build the combined package on CI
var windows = GetFiles ("./nuget/*.Windows.*nuspec").Select (f => f.FullPath);
var mac = GetFiles ("./nuget/*.Mac.*nuspec").Select (f => f.FullPath);
var linux = GetFiles ("./nuget/*.Linux.*nuspec").Select (f => f.FullPath);
var all = GetFiles ("./nuget/*.All.*nuspec").Select (f => f.FullPath);
var finals = GetFiles ("./nuget/*.nuspec").Select (f => f.FullPath);
finals = finals.Except (windows).Except (mac).Except (linux).Except (all);
var toPack = all;
if (IS_ON_FINAL_CI) {
PackageNuGet ("./nuget/SkiaSharp.nuspec", "./output/");
PackageNuGet ("./nuget/HarfBuzzSharp.nuspec", "./output/");
PackageNuGet ("./nuget/SkiaSharp.Views.nuspec", "./output/");
PackageNuGet ("./nuget/SkiaSharp.Views.Forms.nuspec", "./output/");
// we can only build the combined package on CI
toPack = toPack.Union (finals);
} else {
if (IsRunningOnWindows ()) {
PackageNuGet ("./nuget/SkiaSharp.Windows.nuspec", "./output/");
PackageNuGet ("./nuget/HarfBuzzSharp.Windows.nuspec", "./output/");
PackageNuGet ("./nuget/SkiaSharp.Views.Windows.nuspec", "./output/");
PackageNuGet ("./nuget/SkiaSharp.Views.Forms.Windows.nuspec", "./output/");
toPack = toPack.Union (windows);
}
if (IsRunningOnMac ()) {
PackageNuGet ("./nuget/SkiaSharp.Mac.nuspec", "./output/");
PackageNuGet ("./nuget/HarfBuzzSharp.Mac.nuspec", "./output/");
PackageNuGet ("./nuget/SkiaSharp.Views.Mac.nuspec", "./output/");
PackageNuGet ("./nuget/SkiaSharp.Views.Forms.Mac.nuspec", "./output/");
toPack = toPack.Union (mac);
}
if (IsRunningOnLinux ()) {
PackageNuGet ("./nuget/SkiaSharp.Linux.nuspec", "./output/");
PackageNuGet ("./nuget/HarfBuzzSharp.Linux.nuspec", "./output/");
PackageNuGet ("./nuget/SkiaSharp.Views.Linux.nuspec", "./output/");
toPack = toPack.Union (linux);
}
}
// HarfBuzz is a PCL
PackageNuGet ("./nuget/SkiaSharp.HarfBuzz.nuspec", "./output/");
foreach (var nuspec in toPack) {
PackageNuGet (nuspec, "./output/");
}
});
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -547,6 +547,19 @@ Task ("set-versions")
sha = "{GIT_SHA}";
}
// set the build number for the preview nugets
var buildNumber = EnvironmentVariable ("BUILD_NUMBER") ?? string.Empty;
if (string.IsNullOrEmpty (buildNumber)) {
buildNumber = "0";
}
// make a copy of the nuspecs to have a preview release
DeleteFiles ("./nuget/*.prerelease.nuspec");
foreach (var file in GetFiles ("./nuget/*.nuspec")) {
var newFile = file.GetDirectory ().CombineWithFilePath (file.GetFilenameWithoutExtension () + ".prerelease.nuspec");
CopyFile (file, newFile);
}
var files = new List<string> ();
var add = new Action<string> (glob => {
files.AddRange (GetFiles (glob).Select (p => MakeAbsolute (p).ToString ()));
@ -556,7 +569,7 @@ Task ("set-versions")
add ("./tests/**/*.csproj");
// update
foreach (var file in files) {
UpdateSkiaSharpVersion (file, VERSION_PACKAGES);
UpdateSkiaSharpVersion (file, VERSION_PACKAGES, "-build-" + buildNumber);
}
// assembly infos
@ -619,6 +632,8 @@ Task ("clean-managed").Does (() =>
CleanDirectories ("./externals/Windows.Foundation.UniversalApiContract/bin");
CleanDirectories ("./externals/Windows.Foundation.UniversalApiContract/obj");
DeleteFiles ("./nuget/*.prerelease.nuspec");
if (DirectoryExists ("./output"))
DeleteDirectory ("./output", true);
});

Просмотреть файл

@ -1,13 +1,14 @@
var MSBuildNS = (XNamespace) "http://schemas.microsoft.com/developer/msbuild/2003";
var UpdateSkiaSharpVersion = new Action<FilePath, Dictionary<string, string>> ((path, versions) => {
var UpdateSkiaSharpVersion = new Action<FilePath, Dictionary<string, string>, string> ((path, versions, previewSuffix) => {
path = MakeAbsolute (path);
var fn = path.GetFilename ().ToString ();
var ext = path.GetExtension ();
if (ext == ".nuspec") {
// NuGet
var suffix = fn.EndsWith (".prerelease.nuspec") ? previewSuffix : "";
var modified = false;
var xdoc = XDocument.Load (path.ToString ());
// <dependency>
@ -24,10 +25,12 @@ var UpdateSkiaSharpVersion = new Action<FilePath, Dictionary<string, string>> ((
var oldVersion = package.Attribute ("version");
if (id != null && oldVersion != null) {
string version;
if (versions.TryGetValue (id.Value, out version) &&
version != oldVersion.Value) {
oldVersion.Value = version;
modified = true;
if (versions.TryGetValue (id.Value, out version)) {
version += suffix;
if (version != oldVersion.Value) {
oldVersion.Value = version;
modified = true;
}
}
}
}
@ -36,10 +39,12 @@ var UpdateSkiaSharpVersion = new Action<FilePath, Dictionary<string, string>> ((
var xVersion = metadata.Elements ("version").FirstOrDefault ();
if (xId != null && xVersion != null) {
string version;
if (versions.TryGetValue (xId.Value, out version) &&
version != xVersion.Value) {
xVersion.Value = version;
modified = true;
if (versions.TryGetValue (xId.Value, out version)) {
version += suffix;
if (version != xVersion.Value) {
xVersion.Value = version;
modified = true;
}
}
}
if (modified) {

Просмотреть файл

@ -171,7 +171,7 @@ var RunGenApi = new Action<FilePath, FilePath> ((input, output) =>
"[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)1)]");
});
var ClearSkiaSharpNuGetCache = new Action (() => {
var ClearSkiaSharpNuGetCache = new Action<string[]> ((packages) => {
// first we need to add our new nuget to the cache so we can restore
// we first need to delete the old stuff
var packagesDir = EnvironmentVariable ("NUGET_PACKAGES");
@ -180,7 +180,6 @@ var ClearSkiaSharpNuGetCache = new Action (() => {
packagesDir = ((DirectoryPath) home).Combine (".nuget").Combine ("packages").ToString();
}
var installedNuGet = packagesDir + "/*";
var packages = VERSION_PACKAGES.Keys;
var dirs = GetDirectories (installedNuGet);
foreach (var pkg in packages) {
Information ("Looking for an installed version of {0} in {1}...", pkg, installedNuGet);
@ -208,7 +207,7 @@ var DecompressArchive = new Action<FilePath, DirectoryPath> ((archive, outputDir
}
});
var CreateSamplesZip = new Action<DirectoryPath, DirectoryPath> ((samplesDirPath, outputDirPath) => {
var CreateSamplesZip = new Action<DirectoryPath, DirectoryPath, Dictionary<string, string>> ((samplesDirPath, outputDirPath, packageVersions) => {
var workingDir = outputDirPath.Combine ("samples");
// copy the current samples directory
@ -306,13 +305,13 @@ var CreateSamplesZip = new Action<DirectoryPath, DirectoryPath> ((samplesDirPath
// we assume "Desired.Package.Id.<platform>.csproj"
var binding = System.IO.Path.GetFileNameWithoutExtension (System.IO.Path.GetFileNameWithoutExtension (absInclude));
// check to see if we have a specific version
binding = VERSION_PACKAGES.Keys.FirstOrDefault (p => p.Equals (binding, StringComparison.OrdinalIgnoreCase));
binding = packageVersions.Keys.FirstOrDefault (p => p.Equals (binding, StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrWhiteSpace (binding)) {
// add a <PackageReference>
var name = projItem.Name.Namespace + "PackageReference";
projItem.AddAfterSelf (new XElement (name, new object[] {
new XAttribute("Include", binding),
new XAttribute("Version", VERSION_PACKAGES[binding]),
new XAttribute("Version", packageVersions[binding]),
}));
}
}

Просмотреть файл