Skip to content

Commit e32ff6c

Browse files
authored
Merge pull request #1485 from arturcic/feature/build-scripts
Build scripts for Packaging and Publishing GitVersion
2 parents 5b04e97 + 7053806 commit e32ff6c

Some content is hidden

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

64 files changed

+3499
-432
lines changed

.editorconfig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,12 @@ indent_size = 4
77
end_of_line = lf
88
charset = utf-8
99
trim_trailing_whitespace = true
10-
insert_final_newline = true
10+
insert_final_newline = true
11+
12+
[.yml]
13+
indent_style = space
14+
indent_size = 2
15+
end_of_line = lf
16+
charset = utf-8
17+
trim_trailing_whitespace = true
18+
insert_final_newline = true

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,13 @@ GitVersion.CommandLine/*/
117117

118118
releaseArtifacts
119119
/ILMergeTemp
120+
.dotnet
121+
.cake
122+
artifacts
123+
/src/Docker/**/content
124+
/src/GitVersionTfsTask/scripts
125+
/src/GitVersionTfsTask/*.vsix
126+
/src/GitVersionRubyGem/*.gem
127+
/src/GitVersionRubyGem/bin/lib
128+
/src/GitVersionRubyGem/bin/GitVersion.exe
129+
/src/GitVersionRubyGem/bin/LibGit2Sharp.dll.config

.travis.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
language: csharp
22
sudo: required
33
dist: trusty
4-
dotnet: 2.1.105
4+
dotnet: 2.1.401
55
mono:
66
- latest
77
os:
88
- linux
99
- osx
1010
before_install:
11-
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
11+
- 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
14+
- bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh)
1215
script:
13-
- ./build.sh -v Diagnostic
16+
- pwsh ./run.ps1 -script run.cake -target Default
1417
env:
1518
global:
1619
- DOTNET_CLI_TELEMETRY_OPTOUT: 1
17-
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
20+
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

README.md

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ works out the [semantic version][semver] of the commit being built.
77
[![Gitter][gitter-badge]][gitter]
88
[![Build status][appveyor-badge]][appveyor]
99
[![Build Status][travis-badge]][travis]
10+
[![Build Status][azure-pipeline-badge]][azure-pipeline]
1011

1112
| | Stable | Pre-release |
1213
| -------------------------: | :---------------------------------------: | :---------------------------------------: |
@@ -51,38 +52,40 @@ target="_blank">Tree</a> designed by <a
5152
href="http://thenounproject.com/david.chapman" target="_blank">David Chapman</a>
5253
from The Noun Project
5354

54-
[icon]: https://raw.github.com/GitTools/GitVersion/master/docs/img/package_icon.png
55-
[semver]: http://semver.org
56-
[gitter]: https://gitter.im/GitTools/GitVersion?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
57-
[gitter-badge]: https://badges.gitter.im/Join+Chat.svg
58-
[appveyor]: https://ci.appveyor.com/project/GitTools/gitversion/branch/master
59-
[appveyor-badge]: https://ci.appveyor.com/api/projects/status/sxje0wht0cscmn7w/branch/master?svg=true
60-
[travis]: https://travis-ci.org/GitTools/GitVersion
61-
[travis-badge]: https://travis-ci.org/GitTools/GitVersion.svg?branch=master
62-
[docs]: http://gitversion.readthedocs.org/en/stable/
63-
[docs-badge]: https://readthedocs.org/projects/gitversion/badge/?version=stable
64-
[docs-pre]: http://gitversion.readthedocs.org/en/latest/
65-
[docs-pre-badge]: https://readthedocs.org/projects/gitversion/badge/?version=latest
66-
[gh-rel]: https://github.com/GitTools/GitVersion/releases/latest
67-
[gh-rel-badge]: https://img.shields.io/github/release/gittools/gitversion.svg
68-
[choco]: https://chocolatey.org/packages/GitVersion.Portable
69-
[choco-badge]: https://img.shields.io/chocolatey/v/gitversion.portable.svg
70-
[choco-pre-badge]: https://img.shields.io/chocolatey/vpre/gitversion.portable.svg
71-
[gvt]: https://www.nuget.org/packages/GitVersionTask
72-
[gvt-badge]: https://img.shields.io/nuget/v/GitVersionTask.svg
73-
[gvt-pre-badge]: https://img.shields.io/nuget/vpre/GitVersionTask.svg
74-
[gvc]: https://www.nuget.org/packages/GitVersion.CommandLine
75-
[gvc-badge]: https://img.shields.io/nuget/v/GitVersion.CommandLine.svg
76-
[gvc-pre-badge]: https://img.shields.io/nuget/vpre/GitVersion.CommandLine.svg
77-
[gem-badge]: https://img.shields.io/gem/v/gitversion.svg
78-
[gem]: https://rubygems.org/gems/gitversion
79-
[brew]: http://brew.sh/
80-
[brew-badge]: https://img.shields.io/homebrew/v/gitversion.svg
81-
[contribute]: https://github.com/GitTools/GitVersion/blob/master/CONTRIBUTING.md
82-
[why]: http://gitversion.readthedocs.org/en/latest/why
83-
[usage]: http://gitversion.readthedocs.org/en/latest/usage/usage/
84-
[how]: http://gitversion.readthedocs.org/en/latest/more-info/how-it-works/
85-
[faq]: http://gitversion.readthedocs.org/en/latest/faq/
86-
[who]: http://gitversion.readthedocs.org/en/latest/who/
87-
[gv-in-action]: https://raw.github.com/GitTools/GitVersion/master/docs/img/README.png
88-
[dockerhub]: https://hub.docker.com/r/gittools/gitversion/
55+
[icon]: https://raw.github.com/GitTools/GitVersion/master/docs/img/package_icon.png
56+
[semver]: http://semver.org
57+
[gitter]: https://gitter.im/GitTools/GitVersion?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
58+
[gitter-badge]: https://badges.gitter.im/Join+Chat.svg
59+
[appveyor]: https://ci.appveyor.com/project/GitTools/gitversion/branch/master
60+
[appveyor-badge]: https://ci.appveyor.com/api/projects/status/sxje0wht0cscmn7w/branch/master?svg=true
61+
<!-- [azure-pipeline]: https://dev.azure.com/arturcic/OSS/_build/latest?definitionId=2 -->
62+
<!-- [azure-pipeline-badge]: https://dev.azure.com/arturcic/OSS/_apis/build/status/GitVersion -->
63+
[travis]: https://travis-ci.org/GitTools/GitVersion
64+
[travis-badge]: https://travis-ci.org/GitTools/GitVersion.svg?branch=master
65+
[docs]: http://gitversion.readthedocs.org/en/stable/
66+
[docs-badge]: https://readthedocs.org/projects/gitversion/badge/?version=stable
67+
[docs-pre]: http://gitversion.readthedocs.org/en/latest/
68+
[docs-pre-badge]: https://readthedocs.org/projects/gitversion/badge/?version=latest
69+
[gh-rel]: https://github.com/GitTools/GitVersion/releases/latest
70+
[gh-rel-badge]: https://img.shields.io/github/release/gittools/gitversion.svg
71+
[choco]: https://chocolatey.org/packages/GitVersion.Portable
72+
[choco-badge]: https://img.shields.io/chocolatey/v/gitversion.portable.svg
73+
[choco-pre-badge]: https://img.shields.io/chocolatey/vpre/gitversion.portable.svg
74+
[gvt]: https://www.nuget.org/packages/GitVersionTask
75+
[gvt-badge]: https://img.shields.io/nuget/v/GitVersionTask.svg
76+
[gvt-pre-badge]: https://img.shields.io/nuget/vpre/GitVersionTask.svg
77+
[gvc]: https://www.nuget.org/packages/GitVersion.CommandLine
78+
[gvc-badge]: https://img.shields.io/nuget/v/GitVersion.CommandLine.svg
79+
[gvc-pre-badge]: https://img.shields.io/nuget/vpre/GitVersion.CommandLine.svg
80+
[gem-badge]: https://img.shields.io/gem/v/gitversion.svg
81+
[gem]: https://rubygems.org/gems/gitversion
82+
[brew]: http://brew.sh/
83+
[brew-badge]: https://img.shields.io/homebrew/v/gitversion.svg
84+
[contribute]: https://github.com/GitTools/GitVersion/blob/master/CONTRIBUTING.md
85+
[why]: http://gitversion.readthedocs.org/en/latest/why
86+
[usage]: http://gitversion.readthedocs.org/en/latest/usage/usage/
87+
[how]: http://gitversion.readthedocs.org/en/latest/more-info/how-it-works/
88+
[faq]: http://gitversion.readthedocs.org/en/latest/faq/
89+
[who]: http://gitversion.readthedocs.org/en/latest/who/
90+
[gv-in-action]: https://raw.github.com/GitTools/GitVersion/master/docs/img/README.png
91+
[dockerhub]: https://hub.docker.com/r/gittools/gitversion/

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-
- ps: .\build.ps1
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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
jobs:
2+
- job: macOS
3+
pool:
4+
vmImage: 'macOS 10.13'
5+
steps:
6+
- task: DotNetCoreInstaller@0
7+
displayName: 'Use .NET Core sdk 2.1.401'
8+
inputs:
9+
version: 2.1.401
10+
- powershell: ./run.ps1 -script run.cake -target Default
11+
displayName: 'Cake build'
12+
- job: Linux
13+
pool:
14+
vmImage: 'Ubuntu 16.04'
15+
steps:
16+
- task: DotNetCoreInstaller@0
17+
displayName: 'Use .NET Core sdk 2.1.401'
18+
inputs:
19+
version: 2.1.401
20+
- task: UseRubyVersion@0
21+
inputs:
22+
addToPath: true # Optional
23+
- powershell: ./run.ps1 -script run.cake -target Default
24+
displayName: 'Cake build'
25+
- job: Windows
26+
pool:
27+
vmImage: 'VS2017-Win2016'
28+
steps:
29+
- task: DotNetCoreInstaller@0
30+
displayName: 'Use .NET Core sdk 2.1.401'
31+
inputs:
32+
version: 2.1.401
33+
- task: UseRubyVersion@0
34+
inputs:
35+
addToPath: true # Optional
36+
- powershell: ./run.ps1 -script run.cake -target Default
37+
displayName: 'Cake build'

build.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ Task("Upload-AppVeyor-Artifacts")
477477
Error(exception.Dump());
478478
});
479479

480-
Task("Travis")
480+
Task("Unix")
481481
.IsDependentOn("Run-Tests");
482482

483483
Task("Default")

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+
}

0 commit comments

Comments
 (0)