Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkone authored Oct 10, 2019
2 parents 1afe5f5 + a4325e0 commit 70b4a35
Show file tree
Hide file tree
Showing 41 changed files with 612 additions and 444 deletions.
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

14 changes: 7 additions & 7 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// Install modules
#module nuget:?package=Cake.DotNetTool.Module&version=0.3.0
#module nuget:?package=Cake.DotNetTool.Module&version=0.3.1

// Install addins.
#addin "nuget:?package=Cake.Codecov&version=0.7.0"
#addin "nuget:?package=Cake.Coverlet&version=2.3.4"
#addin "nuget:?package=Cake.Docker&version=0.10.1"
#addin "nuget:?package=Cake.Gem&version=0.8.0"
#addin "nuget:?package=Cake.Gitter&version=0.11.0"
#addin "nuget:?package=Cake.Gem&version=0.8.1"
#addin "nuget:?package=Cake.Gitter&version=0.11.1"
#addin "nuget:?package=Cake.Incubator&version=5.1.0"
#addin "nuget:?package=Cake.Json&version=4.0.0"
#addin "nuget:?package=Cake.Npm&version=0.17.0"
#addin "nuget:?package=Cake.Tfx&version=0.9.0"
#addin "nuget:?package=Cake.Tfx&version=0.9.1"

#addin "nuget:?package=Newtonsoft.Json&version=11.0.2"
#addin "nuget:?package=Newtonsoft.Json&version=12.0.2"
#addin "nuget:?package=xunit.assert&version=2.4.1"

// Install tools.
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.10.0"
#tool "nuget:?package=ILRepack&version=2.0.17"
#tool "nuget:?package=nuget.commandline&version=5.1.0"
#tool "nuget:?package=ILRepack&version=2.0.18"
#tool "nuget:?package=nuget.commandline&version=5.2.0"

// Install .NET Core Global tools.
#tool "dotnet:?package=Codecov.Tool&version=1.7.2"
Expand Down
2 changes: 1 addition & 1 deletion build.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
CAKE_VERSION=0.34.1
CAKE_VERSION=0.35
DOTNET_VERSION=2.2.401
48 changes: 29 additions & 19 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ $DotNetChannel = 'LTS'
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent

[string] $CakeVersion = ''
[string] $DotNetVersion= ''
[string[]] $DotNetVersion= ''
foreach($line in Get-Content (Join-Path $PSScriptRoot 'build.config'))
{
if ($line -like 'CAKE_VERSION=*') {
$CakeVersion = $line.SubString(13)
}
elseif ($line -like 'DOTNET_VERSION=*') {
$DotNetVersion =$line.SubString(15)
$DotNetVersion = $line.SubString(15).Split(',')
}
}

Expand Down Expand Up @@ -110,40 +110,50 @@ Function Remove-PathVariable([string]$VariableToRemove)
}
}

# Get .NET Core CLI path if installed.
$FoundDotNetCliVersion = $null;
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
$FoundDotNetCliVersion = dotnet --version;
}

if($FoundDotNetCliVersion -ne $DotNetVersion) {
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
if (!(Test-Path $InstallPath)) {
New-Item -Path $InstallPath -ItemType Directory -Force | Out-Null;
Function Add-PathVariable([string]$PathToAdd)
{
$SplitChar = ';'
if ($IsMacOS -or $IsLinux) {
$SplitChar = ':'
}

$env:PATH = "$($PathToAdd)$($SplitChar)$env:PATH"
}

Function Install-Dotnet($DotNetVersion)
{
if ($IsMacOS -or $IsLinux) {
$ScriptPath = Join-Path $InstallPath 'dotnet-install.sh'
(New-Object System.Net.WebClient).DownloadFile($DotNetUnixInstallerUri, $ScriptPath);

& bash $ScriptPath --version "$DotNetVersion" --install-dir "$InstallPath" --channel "$DotNetChannel" --no-path
Remove-PathVariable "$InstallPath"
$env:PATH = "$($InstallPath):$env:PATH"
}
else {
$ScriptPath = Join-Path $InstallPath 'dotnet-install.ps1'
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, $ScriptPath);
& $ScriptPath -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;

Remove-PathVariable "$InstallPath"
$env:PATH = "$InstallPath;$env:PATH"
& $ScriptPath -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;
}
$env:DOTNET_ROOT=$InstallPath
}

# Get .NET Core CLI path if installed.
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
if (!(Test-Path $InstallPath)) {
New-Item -Path $InstallPath -ItemType Directory -Force | Out-Null;
}

foreach($version in $DotNetVersion)
{
Install-Dotnet $version
}

Remove-PathVariable "$InstallPath"
Add-PathVariable "$InstallPath"
$env:DOTNET_ROOT=$InstallPath

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1


###########################################################################
# INSTALL CAKE
###########################################################################
Expand Down
38 changes: 12 additions & 26 deletions build/pack.cake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Task("Test")
.IsDependentOn("Build")
.Does<BuildParameters>((parameters) =>
{
var frameworks = new[] { parameters.CoreFxVersion, parameters.FullFxVersion };
var frameworks = new[] { parameters.CoreFxVersion21, parameters.FullFxVersion };
var testResultsPath = parameters.Paths.Directories.TestResultsOutput;
foreach(var framework in frameworks)
Expand Down Expand Up @@ -125,26 +125,26 @@ Task("Copy-Files")
.Does<BuildParameters>((parameters) =>
{
// .NET Core
var coreFxDir = parameters.Paths.Directories.ArtifactsBinCoreFx.Combine("tools");
var coreFxDir = parameters.Paths.Directories.ArtifactsBinCoreFx21.Combine("tools");
DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", new DotNetCorePublishSettings
{
Framework = parameters.CoreFxVersion,
NoRestore = true,
Framework = parameters.CoreFxVersion21,
NoRestore = false,
Configuration = parameters.Configuration,
OutputDirectory = coreFxDir,
MSBuildSettings = parameters.MSBuildSettings
});
// Copy license & Copy GitVersion.XML (since publish does not do this anymore)
CopyFileToDirectory("./LICENSE", coreFxDir);
CopyFileToDirectory($"./src/GitVersionExe/bin/{parameters.Configuration}/{parameters.CoreFxVersion}/GitVersion.xml", coreFxDir);
CopyFileToDirectory($"./src/GitVersionExe/bin/{parameters.Configuration}/{parameters.CoreFxVersion21}/GitVersion.xml", coreFxDir);
// .NET Framework
DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", new DotNetCorePublishSettings
{
Framework = parameters.FullFxVersion,
NoBuild = true,
NoRestore = true,
NoRestore = false,
Configuration = parameters.Configuration,
OutputDirectory = parameters.Paths.Directories.ArtifactsBinFullFx,
MSBuildSettings = parameters.MSBuildSettings
Expand All @@ -162,7 +162,7 @@ Task("Copy-Files")
// .NET Core
DotNetCorePublish("./src/GitVersionTask/GitVersionTask.csproj", new DotNetCorePublishSettings
{
Framework = parameters.CoreFxVersion,
Framework = parameters.CoreFxVersion21,
NoBuild = true,
NoRestore = true,
Configuration = parameters.Configuration,
Expand All @@ -173,23 +173,9 @@ Task("Copy-Files")
var cmdlineDir = parameters.Paths.Directories.ArtifactsBinFullFxCmdline.Combine("tools");
// Portable
PublishILRepackedGitVersionExe(true, parameters.Paths.Directories.ArtifactsBinFullFx, ilMergeDir, portableDir, parameters.Configuration, parameters.FullFxVersion);
PublishILRepackedGitVersionExe(true, ilMergeDir, portableDir, parameters);
// Commandline
PublishILRepackedGitVersionExe(false, parameters.Paths.Directories.ArtifactsBinFullFx, ilMergeDir, cmdlineDir, parameters.Configuration, parameters.FullFxVersion);
// Vsix
var vsixPath = new DirectoryPath("./src/GitVersionVsixTask/GitVersionTask");
var vsixPathFull = vsixPath.Combine("full");
EnsureDirectoryExists(vsixPathFull);
CopyFileToDirectory(portableDir + "/" + "LibGit2Sharp.dll.config", vsixPathFull);
CopyFileToDirectory(portableDir + "/" + "GitVersion.exe", vsixPathFull);
CopyDirectory(portableDir.Combine("lib"), vsixPathFull.Combine("lib"));
// Vsix dotnet core
var vsixPathCore = vsixPath.Combine("core");
EnsureDirectoryExists(vsixPathCore);
CopyDirectory(coreFxDir, vsixPathCore);
PublishILRepackedGitVersionExe(false, ilMergeDir, cmdlineDir, parameters);
// Ruby Gem
var gemPath = new DirectoryPath("./src/GitVersionRubyGem/bin");
Expand All @@ -200,14 +186,14 @@ Task("Copy-Files")
});

Task("Pack-Vsix")
.IsDependentOn("Copy-Files")
.IsDependentOn("Test")
.Does<BuildParameters>((parameters) =>
{
var workDir = "./src/GitVersionVsixTask";
var idSuffix = parameters.IsStableRelease() ? "" : "-preview";
var titleSuffix = parameters.IsStableRelease() ? "" : " (Preview)";
var visibility = parameters.IsStableRelease() ? "Public" : "Preview";
var taskId = parameters.IsStableRelease() ? "e5983830-3f75-11e5-82ed-81492570a08e" : "25b46667-d5a9-4665-97f7-e23de366ecdf";
var taskId = parameters.IsStableRelease() ? "bab30d5c-39f3-49b0-a7db-9a5da6676eaa" : "dd065e3b-6aef-46af-845c-520195836b35";
ReplaceTextInFile(new FilePath(workDir + "/vss-extension.json"), "$idSuffix$", idSuffix);
ReplaceTextInFile(new FilePath(workDir + "/vss-extension.json"), "$titleSuffix$", titleSuffix);
Expand Down Expand Up @@ -325,7 +311,7 @@ Task("Zip-Files")
Zip(cmdlineDir, parameters.Paths.Files.ZipArtifactPathDesktop, fullFxFiles);
// .NET Core
var coreFxDir = parameters.Paths.Directories.ArtifactsBinCoreFx.Combine("tools");
var coreFxDir = parameters.Paths.Directories.ArtifactsBinCoreFx21.Combine("tools");
var coreclrFiles = GetFiles(coreFxDir.FullPath + "/**/*");
Zip(coreFxDir, parameters.Paths.Files.ZipArtifactPathCoreClr, coreclrFiles);
});
Expand Down
4 changes: 2 additions & 2 deletions build/publish.cake
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ Task("Publish-AzurePipeline")
{
foreach(var artifact in parameters.Artifacts.All)
{
if (FileExists(artifact.ArtifactPath)) { TFBuild.Commands.UploadArtifact(artifact.ContainerName, artifact.ArtifactPath, artifact.ArtifactName); }
if (FileExists(artifact.ArtifactPath)) { TFBuild.Commands.UploadArtifact("", artifact.ArtifactPath, "artifacts"); }
}
foreach(var package in parameters.Packages.All)
{
if (FileExists(package.PackagePath)) { TFBuild.Commands.UploadArtifact("packages", package.PackagePath, package.PackageName); }
if (FileExists(package.PackagePath)) { TFBuild.Commands.UploadArtifact("", package.PackagePath, "packages"); }
}
})
.OnError(exception =>
Expand Down
2 changes: 1 addition & 1 deletion build/stages/artifacts-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
inputs:
source: current
path: $(Build.SourcesDirectory)
artifact: artifacts
artifact: storage
- script: dotnet cake build.cake --bootstrap && dotnet cake build.cake --target=Artifacts-Test --docker_distro=$(DISTRO) --docker_dotnetversion=$(DOTNET_VERSION)
displayName: 'Docker build'
2 changes: 1 addition & 1 deletion build/stages/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ steps:
- publish: $(System.DefaultWorkingDirectory)
displayName: 'Upload pipeline artifacts'
condition: eq( variables['Agent.OS'], 'Windows_NT' )
artifact: artifacts
artifact: storage
2 changes: 1 addition & 1 deletion build/stages/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
inputs:
source: current
path: $(Build.SourcesDirectory)
artifact: artifacts
artifact: storage
- script: dotnet cake build.cake --bootstrap && dotnet cake build.cake --target=Publish-DockerHub --docker_distro=$(DISTRO) --docker_dotnetversion=$(DOTNET_VERSION)
displayName: 'Docker build'
env:
Expand Down
2 changes: 1 addition & 1 deletion build/stages/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ steps:
inputs:
source: current
path: $(Build.SourcesDirectory)
artifact: artifacts
artifact: storage
- script: dotnet cake build.cake --bootstrap && dotnet cake build.cake --target=Publish
displayName: 'Publish'
env:
Expand Down
2 changes: 1 addition & 1 deletion build/stages/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ steps:
inputs:
source: current
path: $(Build.SourcesDirectory)
artifact: artifacts
artifact: storage
- script: dotnet cake build.cake --bootstrap && dotnet cake build.cake --target=Release
displayName: 'Release'
env:
Expand Down
4 changes: 2 additions & 2 deletions build/utils/docker.cake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void DockerBuild(DockerImage dockerImage, BuildParameters parameters)
var workDir = DirectoryPath.FromString($"./src/Docker");

var sourceDir = targetframework.StartsWith("netcoreapp")
? parameters.Paths.Directories.ArtifactsBinCoreFx.Combine("tools")
? parameters.Paths.Directories.ArtifactsBinCoreFx21.Combine("tools")
: parameters.Paths.Directories.ArtifactsBinFullFxCmdline.Combine("tools");

CopyDirectory(sourceDir, workDir.Combine("content"));
Expand Down Expand Up @@ -130,7 +130,7 @@ string[] GetDockerTags(DockerImage dockerImage, BuildParameters parameters) {
$"{name}:{parameters.Version.SemVersion}-{os}-{distro}-{targetframework}",
};

if (distro == "debian-9" && targetframework == parameters.CoreFxVersion || distro == "nanoserver-1809") {
if (distro == "debian-9" && targetframework == parameters.CoreFxVersion21 || distro == "nanoserver-1809") {
tags.AddRange(new[] {
$"{name}:{parameters.Version.Version}-{os}",
$"{name}:{parameters.Version.SemVersion}-{os}",
Expand Down
32 changes: 16 additions & 16 deletions build/utils/parameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ public class BuildParameters
public string Target { get; private set; }
public string Configuration { get; private set; }

public string CoreFxVersion { get; private set; } = "netcoreapp2.1";
public const string MainRepoOwner = "gittools";
public const string MainRepoName = "GitVersion";
public string CoreFxVersion21 { get; private set; } = "netcoreapp2.1";
public string FullFxVersion { get; private set; } = "net472";

public string DockerDistro { get; private set; }
Expand Down Expand Up @@ -118,21 +120,20 @@ public class BuildParameters
Packages = BuildPackages.GetPackages(
Paths.Directories.NugetRoot,
Version,
new [] { "GitVersion.CommandLine.DotNetCore", "GitVersion.CommandLine", "GitVersionTask", "GitVersion.Tool" },
new [] { "GitVersion.CommandLine", "GitVersionTask", "GitVersion.Tool" },
new [] { "GitVersion.Portable" });

var files = Paths.Files;
Artifacts = BuildArtifacts.GetArtifacts(new[] {
files.ZipArtifactPathDesktop,
files.ZipArtifactPathCoreClr,
files.ReleaseNotesOutputFilePath,
files.VsixOutputFilePath,
files.GemOutputFilePath
});

var buildArtifacts = context.GetFiles(Paths.Directories.BuildArtifact + "/*.*");
buildArtifacts += files.ZipArtifactPathDesktop;
buildArtifacts += files.ZipArtifactPathCoreClr;
buildArtifacts += files.ReleaseNotesOutputFilePath;

Artifacts = BuildArtifacts.GetArtifacts(buildArtifacts.ToArray());

PackagesBuildMap = new Dictionary<string, DirectoryPath>
{
["GitVersion.CommandLine.DotNetCore"] = Paths.Directories.ArtifactsBinCoreFx,
["GitVersion.CommandLine"] = Paths.Directories.ArtifactsBinFullFxCmdline,
["GitVersion.Portable"] = Paths.Directories.ArtifactsBinFullFxPortable,
};
Expand Down Expand Up @@ -194,13 +195,13 @@ public class BuildParameters

context.Information("Repository Name: {0}" , repositoryName);

return !string.IsNullOrWhiteSpace(repositoryName) && StringComparer.OrdinalIgnoreCase.Equals("gittools/gitversion", repositoryName);
return !string.IsNullOrWhiteSpace(repositoryName) && StringComparer.OrdinalIgnoreCase.Equals($"{BuildParameters.MainRepoOwner}/{BuildParameters.MainRepoName}", repositoryName);
}

private static bool IsOnMainBranch(ICakeContext context)
{
var buildSystem = context.BuildSystem();
string repositoryBranch = null;
string repositoryBranch = ExecGitCmd(context, "rev-parse --abbrev-ref HEAD").Single();
if (buildSystem.IsRunningOnAppVeyor)
{
repositoryBranch = buildSystem.AppVeyor.Environment.Repository.Branch;
Expand All @@ -221,10 +222,9 @@ public class BuildParameters

private static bool IsBuildTagged(ICakeContext context)
{
var gitPath = context.Tools.Resolve(context.IsRunningOnWindows() ? "git.exe" : "git");
context.StartProcess(gitPath, new ProcessSettings { Arguments = "rev-parse --verify HEAD", RedirectStandardOutput = true }, out var sha);
context.StartProcess(gitPath, new ProcessSettings { Arguments = "tag --points-at " + sha.Single(), RedirectStandardOutput = true }, out var redirectedOutput);
var sha = ExecGitCmd(context, "rev-parse --verify HEAD").Single();
var isTagged = ExecGitCmd(context, "tag --points-at " + sha).Any();

return redirectedOutput.Any();
return isTagged;
}
}
Loading

0 comments on commit 70b4a35

Please sign in to comment.