Skip to content

Commit d96d26d

Browse files
committed
Implemented Nuget, Chocolatey, Docker, Vsix, Gem Publish
Added Azure Pipelines support Building unit tests on unix with nunit
1 parent 2f449f0 commit d96d26d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3239
-217
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,13 @@ releaseArtifacts
119119
/ILMergeTemp
120120
.dotnet
121121
.cake
122+
artifacts
123+
/src/Docker/**/content
124+
/src/GitVersionTfsTask/lib
125+
/src/GitVersionTfsTask/GitVersion.exe
126+
/src/GitVersionTfsTask/LibGit2Sharp.dll.config
127+
/src/GitVersionTfsTask/*.vsix
128+
/src/GitVersionRubyGem/*.gem
129+
/src/GitVersionRubyGem/bin/lib
130+
/src/GitVersionRubyGem/bin/GitVersion.exe
131+
/src/GitVersionRubyGem/bin/LibGit2Sharp.dll.config

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ os:
99
- osx
1010
before_install:
1111
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
12+
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
13+
- git fetch origin
1214
- bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh)
1315
script:
14-
- pwsh ./run.ps1 -script build.cake -target Unix
16+
- pwsh ./run.ps1 -script run.cake -target Default
1517
env:
1618
global:
1719
- DOTNET_CLI_TELEMETRY_OPTOUT: 1

appveyor.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
image: Visual Studio 2017
2-
install:
3-
- npm i -g tfx-cli
42

53
assembly_info:
64
patch: false
75

86
configuration:
97
- Debug
8+
install:
9+
- set PATH=C:\Ruby25-x64\bin;%PATH%
1010

1111
build_script:
12-
- pwsh: ./run.ps1 -script build.cake
12+
- pwsh: ./run.ps1 -script run.cake -target Default
1313

1414
test: off
1515
skip_tags: true
16-
17-
cache:
18-
- src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified

azure-pipelines.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
displayName: 'Use .NET Core sdk 2.1.401'
88
inputs:
99
version: 2.1.401
10-
- powershell: ./run.ps1 -script build.cake -target Unix
10+
- powershell: ./run.ps1 -script run.cake -target Default
1111
displayName: 'Cake build'
1212
- job: Linux
1313
pool:
@@ -17,7 +17,10 @@ jobs:
1717
displayName: 'Use .NET Core sdk 2.1.401'
1818
inputs:
1919
version: 2.1.401
20-
- powershell: ./run.ps1 -script build.cake -target Unix
20+
- task: UseRubyVersion@0
21+
inputs:
22+
addToPath: true # Optional
23+
- powershell: ./run.ps1 -script run.cake -target Default
2124
displayName: 'Cake build'
2225
- job: Windows
2326
pool:
@@ -27,5 +30,8 @@ jobs:
2730
displayName: 'Use .NET Core sdk 2.1.401'
2831
inputs:
2932
version: 2.1.401
30-
- powershell: ./run.ps1 -script build.cake
33+
- task: UseRubyVersion@0
34+
inputs:
35+
addToPath: true # Optional
36+
- powershell: ./run.ps1 -script run.cake -target Default
3137
displayName: 'Cake build'

build/artifacts.cake

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
public class BuildPackages
2+
{
3+
public ICollection<BuildPackage> All { get; private set; }
4+
public ICollection<BuildPackage> Nuget { get; private set; }
5+
public ICollection<BuildPackage> Chocolatey { get; private set; }
6+
7+
public static BuildPackages GetPackages(
8+
DirectoryPath nugetRooPath,
9+
string semVersion,
10+
string[] packageIds,
11+
string[] chocolateyPackageIds)
12+
{
13+
var toNugetPackage = BuildPackage(nugetRooPath, semVersion);
14+
var toChocolateyPackage = BuildPackage(nugetRooPath, semVersion, isChocolateyPackage: true);
15+
var nugetPackages = packageIds.Select(toNugetPackage).ToArray();
16+
var chocolateyPackages = chocolateyPackageIds.Select(toChocolateyPackage).ToArray();
17+
18+
return new BuildPackages {
19+
All = nugetPackages.Union(chocolateyPackages).ToArray(),
20+
Nuget = nugetPackages,
21+
Chocolatey = chocolateyPackages
22+
};
23+
}
24+
25+
private static Func<string, BuildPackage> BuildPackage(
26+
DirectoryPath nugetRooPath,
27+
string semVersion,
28+
bool isChocolateyPackage = false)
29+
{
30+
return package => new BuildPackage(
31+
id: package,
32+
nuspecPath: string.Concat("./nuspec/", package, ".nuspec"),
33+
packagePath: nugetRooPath.CombineWithFilePath(string.Concat(package, ".", semVersion, ".nupkg")),
34+
isChocolateyPackage: isChocolateyPackage);
35+
}
36+
}
37+
38+
public class BuildPackage
39+
{
40+
public string Id { get; private set; }
41+
public FilePath NuspecPath { get; private set; }
42+
public FilePath PackagePath { get; private set; }
43+
public bool IsChocolateyPackage { get; private set; }
44+
public string PackageName { get; private set; }
45+
46+
47+
public BuildPackage(
48+
string id,
49+
FilePath nuspecPath,
50+
FilePath packagePath,
51+
bool isChocolateyPackage)
52+
{
53+
Id = id;
54+
NuspecPath = nuspecPath;
55+
PackagePath = packagePath;
56+
IsChocolateyPackage = isChocolateyPackage;
57+
PackageName = PackagePath.GetFilename().ToString();
58+
}
59+
}
60+
61+
public class BuildArtifacts
62+
{
63+
public ICollection<BuildArtifact> All { get; private set; }
64+
65+
public static BuildArtifacts GetArtifacts(FilePath[] artifacts)
66+
{
67+
var toBuildArtifact = BuildArtifact("build-artifact");
68+
var buildArtifacts = artifacts.Select(toBuildArtifact).ToArray();
69+
70+
return new BuildArtifacts {
71+
All = buildArtifacts.ToArray(),
72+
};
73+
}
74+
75+
private static Func<FilePath, BuildArtifact> BuildArtifact(string containerName)
76+
{
77+
return artifactPath => new BuildArtifact(containerName: containerName, artifactPath: artifactPath);
78+
}
79+
}
80+
81+
public class BuildArtifact
82+
{
83+
public string ContainerName { get; private set; }
84+
public FilePath ArtifactPath { get; private set; }
85+
public string ArtifactName { get; private set; }
86+
87+
public BuildArtifact(
88+
string containerName,
89+
FilePath artifactPath)
90+
{
91+
ContainerName = containerName;
92+
ArtifactPath = artifactPath.FullPath;
93+
ArtifactName = ArtifactPath.GetFilename().ToString();
94+
}
95+
}

build/credentials.cake

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
public class BuildCredentials
2+
{
3+
public GitHubCredentials GitHub { get; private set; }
4+
public GitterCredentials Gitter { get; private set; }
5+
public DockerHubCredentials Docker { get; private set; }
6+
public NugetCredentials Nuget { get; private set; }
7+
public ChocolateyCredentials Chocolatey { get; private set; }
8+
public TfxCredentials Tfx { get; private set; }
9+
public RubyGemCredentials RubyGem { get; private set; }
10+
11+
public static BuildCredentials GetCredentials(ICakeContext context)
12+
{
13+
return new BuildCredentials
14+
{
15+
GitHub = GitHubCredentials.GetGitHubCredentials(context),
16+
Gitter = GitterCredentials.GetGitterCredentials(context),
17+
Docker = DockerHubCredentials.GetDockerHubCredentials(context),
18+
Nuget = NugetCredentials.GetNugetCredentials(context),
19+
Chocolatey = ChocolateyCredentials.GetChocolateyCredentials(context),
20+
Tfx = TfxCredentials.GetTfxCredentials(context),
21+
RubyGem = RubyGemCredentials.GetRubyGemCredentials(context),
22+
};
23+
}
24+
}
25+
26+
public class GitHubCredentials
27+
{
28+
public string UserName { get; private set; }
29+
public string Password { get; private set; }
30+
public string Token { get; private set; }
31+
32+
public GitHubCredentials(string userName, string password, string token)
33+
{
34+
UserName = userName;
35+
Password = password;
36+
Token = token;
37+
}
38+
39+
public static GitHubCredentials GetGitHubCredentials(ICakeContext context)
40+
{
41+
return new GitHubCredentials(
42+
context.EnvironmentVariable("GITHUB_USERNAME"),
43+
context.EnvironmentVariable("GITHUB_PASSWORD"),
44+
context.EnvironmentVariable("GITHUB_TOKEN"));
45+
}
46+
}
47+
48+
public class GitterCredentials
49+
{
50+
public string Token { get; private set; }
51+
public string RoomId { get; private set; }
52+
53+
public GitterCredentials(string token, string roomId)
54+
{
55+
Token = token;
56+
RoomId = roomId;
57+
}
58+
59+
public static GitterCredentials GetGitterCredentials(ICakeContext context)
60+
{
61+
return new GitterCredentials(
62+
context.EnvironmentVariable("GITTER_TOKEN"),
63+
context.EnvironmentVariable("GITTER_ROOM_ID")
64+
);
65+
}
66+
}
67+
68+
public class DockerHubCredentials
69+
{
70+
public string UserName { get; private set; }
71+
public string Password { get; private set; }
72+
73+
public DockerHubCredentials(string userName, string password)
74+
{
75+
UserName = userName;
76+
Password = password;
77+
}
78+
79+
public static DockerHubCredentials GetDockerHubCredentials(ICakeContext context)
80+
{
81+
return new DockerHubCredentials(
82+
context.EnvironmentVariable("DOCKER_USERNAME"),
83+
context.EnvironmentVariable("DOCKER_PASSWORD"));
84+
}
85+
}
86+
87+
public class NugetCredentials
88+
{
89+
public string ApiKey { get; private set; }
90+
public string ApiUrl { get; private set; }
91+
92+
public NugetCredentials(string apiKey, string apiUrl)
93+
{
94+
ApiKey = apiKey;
95+
ApiUrl = apiUrl;
96+
}
97+
98+
public static NugetCredentials GetNugetCredentials(ICakeContext context)
99+
{
100+
return new NugetCredentials(
101+
context.EnvironmentVariable("NUGET_API_KEY"),
102+
context.EnvironmentVariable("NUGET_API_URL"));
103+
}
104+
}
105+
106+
public class ChocolateyCredentials
107+
{
108+
public string ApiKey { get; private set; }
109+
public string ApiUrl { get; private set; }
110+
111+
public ChocolateyCredentials(string apiKey, string apiUrl)
112+
{
113+
ApiKey = apiKey;
114+
ApiUrl = apiUrl;
115+
}
116+
117+
public static ChocolateyCredentials GetChocolateyCredentials(ICakeContext context)
118+
{
119+
return new ChocolateyCredentials(
120+
context.EnvironmentVariable("CHOCOLATEY_API_KEY"),
121+
context.EnvironmentVariable("CHOCOLATEY_API_URL"));
122+
}
123+
}
124+
125+
public class TfxCredentials
126+
{
127+
public string Token { get; private set; }
128+
129+
public TfxCredentials(string token)
130+
{
131+
Token = token;
132+
}
133+
134+
public static TfxCredentials GetTfxCredentials(ICakeContext context)
135+
{
136+
return new TfxCredentials(context.EnvironmentVariable("TFX_TOKEN"));
137+
}
138+
}
139+
140+
public class RubyGemCredentials
141+
{
142+
public string ApiKey { get; private set; }
143+
144+
public RubyGemCredentials(string apiKey)
145+
{
146+
ApiKey = apiKey;
147+
}
148+
149+
public static RubyGemCredentials GetRubyGemCredentials(ICakeContext context)
150+
{
151+
return new RubyGemCredentials(context.EnvironmentVariable("RUBY_GEM_API_KEY"));
152+
}
153+
}

0 commit comments

Comments
 (0)