Skip to content

Commit b6b0176

Browse files
committed
Added support for a fully automated deployment environment
1 parent 664f320 commit b6b0176

File tree

7 files changed

+49
-292
lines changed

7 files changed

+49
-292
lines changed

build/Build.csx

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,50 @@
11
#! "netcoreapp2.0"
2-
#r "nuget:NetStandard.Library,2.0.0"
3-
#r "nuget:Microsoft.DotNet.PlatformAbstractions, 2.0.3"
4-
#load "DotNet.csx"
2+
#load "nuget:Dotnet.Build, 0.2.7"
3+
#load "nuget:github-changelog, 0.1.4"
54
#load "Choco.csx"
6-
#load "NuGet.csx"
7-
#load "FileUtils.csx"
5+
#load "BuildContext.csx"
86

9-
using System.Runtime.InteropServices;
10-
11-
12-
var currentFolder = Path.GetDirectoryName(GetScriptPath());
13-
var root = Path.GetFullPath(Path.Combine(currentFolder, ".."));
14-
15-
16-
DotNet.Build(Path.Combine(root, "src","Dotnet.Script"));
17-
18-
DotNet.Test($"{root}/src/Dotnet.Script.Tests");
7+
using static BuildContext;
8+
using static ReleaseManagement;
9+
using static ChangeLog;
10+
using static FileUtils;
1911

12+
DotNet.Build(DotnetScriptProjectFolder);
13+
DotNet.Test(TestProjectFolder);
14+
DotNet.Publish(DotnetScriptProjectFolder, PublishArtifactsFolder);
2015

2116
// We only publish packages from Windows/AppVeyor
22-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
17+
if (BuildEnvironment.IsWindows)
2318
{
24-
string packagesOutputFolder = Path.Combine(root, "build", "NuGet");
25-
DotNet.Pack(Path.Combine(root, "src" , "Dotnet.Script"), packagesOutputFolder);
26-
DotNet.Pack(Path.Combine(root, "src" , "Dotnet.Script.Core"), packagesOutputFolder);
27-
DotNet.Pack(Path.Combine(root, "src" , "Dotnet.Script.DependencyModel"), packagesOutputFolder);
28-
DotNet.Pack(Path.Combine(root, "src" , "Dotnet.Script.DependencyModel.NuGet"), packagesOutputFolder);
29-
DotNet.Publish($"{root}/src/Dotnet.Script");
30-
Choco.Pack($"{root}/src/Dotnet.Script","Chocolatey");
19+
DotNet.Pack(DotnetScriptProjectFolder, NuGetArtifactsFolder);
20+
DotNet.Pack(DotnetScriptCoreProjectFolder, NuGetArtifactsFolder);
21+
DotNet.Pack(DotnetScriptDependencyModelProjectFolder, NuGetArtifactsFolder);
22+
DotNet.Pack(DotnetScriptDependencyModelNuGetProjectFolder, NuGetArtifactsFolder);
23+
Choco.Pack(DotnetScriptProjectFolder, PublishArtifactsFolder, ChocolateyArtifactsFolder);
24+
Zip(PublishArchiveFolder, PathToGitHubReleaseAsset);
25+
26+
27+
if (BuildEnvironment.IsSecure)
28+
{
29+
await CreateReleaseNotes();
30+
31+
if (Git.Default.IsTagCommit())
32+
{
33+
Git.Default.RequreCleanWorkingTree();
34+
await ReleaseManagerFor(Owner,ProjectName,BuildEnvironment.GitHubAccessToken)
35+
.CreateRelease(Git.Default.GetLatestTag(), PathToReleaseNotes, new [] { new ZipReleaseAsset(PathToGitHubReleaseAsset) });
36+
NuGet.TryPush(NuGetArtifactsFolder);
37+
}
38+
}
3139
}
3240

33-
41+
private async Task CreateReleaseNotes()
42+
{
43+
Logger.Log("Creating release notes");
44+
var generator = ChangeLogFrom(Owner, ProjectName, BuildEnvironment.GitHubAccessToken).SinceLatestTag();
45+
if (!Git.Default.IsTagCommit())
46+
{
47+
generator = generator.IncludeUnreleased();
48+
}
49+
await generator.Generate(PathToReleaseNotes);
50+
}

build/Choco.csx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#load "FileUtils.csx"
2-
#load "DotNet.csx"
3-
#load "Command.csx"
1+
#load "nuget:Dotnet.Build, 0.2.5"
42

53
using System.Xml.Linq;
64

@@ -11,18 +9,15 @@ public static class Choco
119
/// </summary>
1210
/// <param name="pathToProjectFolder">The path to the project folder.</param>
1311
/// <param name="outputFolder">The path to the output folder (*.nupkg)</param>
14-
public static void Pack(string pathToProjectFolder, string outputFolder)
15-
{
16-
DotNet.Publish(pathToProjectFolder);
17-
Directory.CreateDirectory(outputFolder);
18-
var pathToPublishFolder = FileUtils.FindDirectory(Path.Combine(pathToProjectFolder, @"bin\Release"),"publish");
12+
public static void Pack(string pathToProjectFolder, string pathToBinaries, string outputFolder)
13+
{
1914
File.Copy(Path.Combine(pathToProjectFolder, "../../LICENSE"), Path.Combine("Chocolatey","tools","LICENSE.TXT"), true);
20-
string pathToProjectFile = FileUtils.FindFile(pathToProjectFolder, "*.csproj");
21-
CreateSpecificationFromProject(pathToProjectFile, pathToPublishFolder);
15+
string pathToProjectFile = Directory.GetFiles(pathToProjectFolder, "*.csproj").Single();
16+
CreateSpecificationFromProject(pathToProjectFile, pathToBinaries);
2217
Command.Execute("choco.exe", $@"pack Chocolatey\chocolatey.nuspec --outputdirectory {outputFolder}");
2318
}
2419

25-
private static void CreateSpecificationFromProject(string pathToProjectFile, string pathToPublishFolder)
20+
private static void CreateSpecificationFromProject(string pathToProjectFile, string pathToBinaries)
2621
{
2722
var projectFile = XDocument.Load(pathToProjectFile);
2823
var authors = projectFile.Descendants("Authors").SingleOrDefault()?.Value;
@@ -65,9 +60,8 @@ public static class Choco
6560
packageElement.Add(filesElement);
6661

6762
// Add the tools folder that contains "ChocolateyInstall.ps1"
68-
filesElement.Add(CreateFileElement(@"tools\*.*",@"Dotnet.Script\tools"));
69-
var srcFolder = Path.Combine("../",pathToPublishFolder).WithWindowsSlashes();
70-
var srcGlobPattern = $@"{srcFolder}\**\*";
63+
filesElement.Add(CreateFileElement(@"tools\*.*",$@"{packageId}\tools"));
64+
var srcGlobPattern = $@"{pathToBinaries}\**\*";
7165
filesElement.Add(CreateFileElement(srcGlobPattern,packageId));
7266

7367
using (var fileStream = new FileStream("Chocolatey/chocolatey.nuspec",FileMode.Create))

build/Command.csx

Lines changed: 0 additions & 47 deletions
This file was deleted.

build/DotNet.csx

Lines changed: 0 additions & 37 deletions
This file was deleted.

build/FileUtils.csx

Lines changed: 0 additions & 133 deletions
This file was deleted.

build/Logger.csx

Lines changed: 0 additions & 7 deletions
This file was deleted.

build/NuGet.csx

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)