forked from litmus/HeadlessChromium.Puppeteer.Lambda.Dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
70 lines (59 loc) · 2.02 KB
/
build.cake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#addin nuget:?package=SharpZipLib
#addin nuget:?package=Cake.Compression
using System.IO;
using Newtonsoft.Json;
var configuration = Argument("configuration", "Release");
var version = AppVeyor.IsRunningOnAppVeyor ? AppVeyor.Environment.Build.Version : "0-dev";
var releaseBinPath = "./src/HeadlessChromium.Puppeteer.Lambda.Dotnet/bin/Release/netcoreapp2.1";
var artifactsDirectory = "./artifacts";
var target = Argument("target", "Default");
Task("Setup")
.Does(() => {
CreateDirectory(artifactsDirectory);
});
Task("Build")
.IsDependentOn("ExtractChromiumFromNpmPackage")
.Does(() => {
var settings = new DotNetCoreBuildSettings
{
Configuration = configuration,
OutputDirectory = artifactsDirectory,
VersionSuffix = version,
};
DotNetCoreBuild("./src/HeadlessChromium.Puppeteer.Lambda.Dotnet.sln", settings);
});
Task("ExtractChromiumFromNpmPackage")
.Does(() =>
{
var currentNpmTarball = GetNpmTarballUrl();
DownloadFile(currentNpmTarball, "chrome-aws-lambda.tgz");
GZipUncompress("chrome-aws-lambda.tgz", "chrome-aws-lambda");
if(!FileExists("./chrome-aws-lambda/package/bin/chromium.br"))
{
throw new Exception("chromium.br did not extract to expected location");
}
});
Task("UploadNugetPackages")
.Does(() => {
var files = GetFiles(artifactsDirectory + "/*.*nupkg");
foreach(var file in files)
{
Information("Found artifact to publish - {0}", file);
if(AppVeyor.IsRunningOnAppVeyor)
{
AppVeyor.UploadArtifact(file,
settings => settings.SetArtifactType(AppVeyorUploadArtifactType.NuGetPackage));
}
}
});
Task("Default")
.IsDependentOn("Build")
.IsDependentOn("UploadNugetPackages");
string GetNpmTarballUrl()
{
var json = System.IO.File.ReadAllText("package.json");
var package = JsonConvert.DeserializeObject<dynamic>(json);
var version = package.dependencies["chrome-aws-lambda"];
return $"https://registry.npmjs.org/chrome-aws-lambda/-/chrome-aws-lambda-{version}.tgz";
}
RunTarget(target);