Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build scripts for Packaging and Publishing GitVersion #1485

Merged
merged 13 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
insert_final_newline = true

[.yml]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,13 @@ GitVersion.CommandLine/*/

releaseArtifacts
/ILMergeTemp
.dotnet
.cake
artifacts
/src/Docker/**/content
/src/GitVersionTfsTask/scripts
/src/GitVersionTfsTask/*.vsix
/src/GitVersionRubyGem/*.gem
/src/GitVersionRubyGem/bin/lib
/src/GitVersionRubyGem/bin/GitVersion.exe
/src/GitVersionRubyGem/bin/LibGit2Sharp.dll.config
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
language: csharp
sudo: required
dist: trusty
dotnet: 2.1.105
dotnet: 2.1.401
mono:
- latest
os:
- linux
- osx
before_install:
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- git fetch origin
- bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh)
script:
- ./build.sh -v Diagnostic
- pwsh ./run.ps1 -script run.cake -target Default
env:
global:
- DOTNET_CLI_TELEMETRY_OPTOUT: 1
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
73 changes: 38 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ works out the [semantic version][semver] of the commit being built.
[![Gitter][gitter-badge]][gitter]
[![Build status][appveyor-badge]][appveyor]
[![Build Status][travis-badge]][travis]
[![Build Status][azure-pipeline-badge]][azure-pipeline]

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

[icon]: https://raw.github.com/GitTools/GitVersion/master/docs/img/package_icon.png
[semver]: http://semver.org
[gitter]: https://gitter.im/GitTools/GitVersion?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[gitter-badge]: https://badges.gitter.im/Join+Chat.svg
[appveyor]: https://ci.appveyor.com/project/GitTools/gitversion/branch/master
[appveyor-badge]: https://ci.appveyor.com/api/projects/status/sxje0wht0cscmn7w/branch/master?svg=true
[travis]: https://travis-ci.org/GitTools/GitVersion
[travis-badge]: https://travis-ci.org/GitTools/GitVersion.svg?branch=master
[docs]: http://gitversion.readthedocs.org/en/stable/
[docs-badge]: https://readthedocs.org/projects/gitversion/badge/?version=stable
[docs-pre]: http://gitversion.readthedocs.org/en/latest/
[docs-pre-badge]: https://readthedocs.org/projects/gitversion/badge/?version=latest
[gh-rel]: https://github.com/GitTools/GitVersion/releases/latest
[gh-rel-badge]: https://img.shields.io/github/release/gittools/gitversion.svg
[choco]: https://chocolatey.org/packages/GitVersion.Portable
[choco-badge]: https://img.shields.io/chocolatey/v/gitversion.portable.svg
[choco-pre-badge]: https://img.shields.io/chocolatey/vpre/gitversion.portable.svg
[gvt]: https://www.nuget.org/packages/GitVersionTask
[gvt-badge]: https://img.shields.io/nuget/v/GitVersionTask.svg
[gvt-pre-badge]: https://img.shields.io/nuget/vpre/GitVersionTask.svg
[gvc]: https://www.nuget.org/packages/GitVersion.CommandLine
[gvc-badge]: https://img.shields.io/nuget/v/GitVersion.CommandLine.svg
[gvc-pre-badge]: https://img.shields.io/nuget/vpre/GitVersion.CommandLine.svg
[gem-badge]: https://img.shields.io/gem/v/gitversion.svg
[gem]: https://rubygems.org/gems/gitversion
[brew]: http://brew.sh/
[brew-badge]: https://img.shields.io/homebrew/v/gitversion.svg
[contribute]: https://github.com/GitTools/GitVersion/blob/master/CONTRIBUTING.md
[why]: http://gitversion.readthedocs.org/en/latest/why
[usage]: http://gitversion.readthedocs.org/en/latest/usage/usage/
[how]: http://gitversion.readthedocs.org/en/latest/more-info/how-it-works/
[faq]: http://gitversion.readthedocs.org/en/latest/faq/
[who]: http://gitversion.readthedocs.org/en/latest/who/
[gv-in-action]: https://raw.github.com/GitTools/GitVersion/master/docs/img/README.png
[dockerhub]: https://hub.docker.com/r/gittools/gitversion/
[icon]: https://raw.github.com/GitTools/GitVersion/master/docs/img/package_icon.png
[semver]: http://semver.org
[gitter]: https://gitter.im/GitTools/GitVersion?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[gitter-badge]: https://badges.gitter.im/Join+Chat.svg
[appveyor]: https://ci.appveyor.com/project/GitTools/gitversion/branch/master
[appveyor-badge]: https://ci.appveyor.com/api/projects/status/sxje0wht0cscmn7w/branch/master?svg=true
<!-- [azure-pipeline]: https://dev.azure.com/arturcic/OSS/_build/latest?definitionId=2 -->
<!-- [azure-pipeline-badge]: https://dev.azure.com/arturcic/OSS/_apis/build/status/GitVersion -->
[travis]: https://travis-ci.org/GitTools/GitVersion
[travis-badge]: https://travis-ci.org/GitTools/GitVersion.svg?branch=master
[docs]: http://gitversion.readthedocs.org/en/stable/
[docs-badge]: https://readthedocs.org/projects/gitversion/badge/?version=stable
[docs-pre]: http://gitversion.readthedocs.org/en/latest/
[docs-pre-badge]: https://readthedocs.org/projects/gitversion/badge/?version=latest
[gh-rel]: https://github.com/GitTools/GitVersion/releases/latest
[gh-rel-badge]: https://img.shields.io/github/release/gittools/gitversion.svg
[choco]: https://chocolatey.org/packages/GitVersion.Portable
[choco-badge]: https://img.shields.io/chocolatey/v/gitversion.portable.svg
[choco-pre-badge]: https://img.shields.io/chocolatey/vpre/gitversion.portable.svg
[gvt]: https://www.nuget.org/packages/GitVersionTask
[gvt-badge]: https://img.shields.io/nuget/v/GitVersionTask.svg
[gvt-pre-badge]: https://img.shields.io/nuget/vpre/GitVersionTask.svg
[gvc]: https://www.nuget.org/packages/GitVersion.CommandLine
[gvc-badge]: https://img.shields.io/nuget/v/GitVersion.CommandLine.svg
[gvc-pre-badge]: https://img.shields.io/nuget/vpre/GitVersion.CommandLine.svg
[gem-badge]: https://img.shields.io/gem/v/gitversion.svg
[gem]: https://rubygems.org/gems/gitversion
[brew]: http://brew.sh/
[brew-badge]: https://img.shields.io/homebrew/v/gitversion.svg
[contribute]: https://github.com/GitTools/GitVersion/blob/master/CONTRIBUTING.md
[why]: http://gitversion.readthedocs.org/en/latest/why
[usage]: http://gitversion.readthedocs.org/en/latest/usage/usage/
[how]: http://gitversion.readthedocs.org/en/latest/more-info/how-it-works/
[faq]: http://gitversion.readthedocs.org/en/latest/faq/
[who]: http://gitversion.readthedocs.org/en/latest/who/
[gv-in-action]: https://raw.github.com/GitTools/GitVersion/master/docs/img/README.png
[dockerhub]: https://hub.docker.com/r/gittools/gitversion/
9 changes: 3 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
image: Visual Studio 2017
install:
npm i -g tfx-cli

assembly_info:
patch: false

configuration:
- Debug
install:
- set PATH=C:\Ruby25-x64\bin;%PATH%

build_script:
- ps: .\build.ps1
- pwsh: ./run.ps1 -script run.cake -target Default

test: off
skip_tags: true

cache:
- src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified
37 changes: 37 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
jobs:
- job: macOS
pool:
vmImage: 'macOS 10.13'
steps:
- task: DotNetCoreInstaller@0
displayName: 'Use .NET Core sdk 2.1.401'
inputs:
version: 2.1.401
- powershell: ./run.ps1 -script run.cake -target Default
displayName: 'Cake build'
- job: Linux
pool:
vmImage: 'Ubuntu 16.04'
steps:
- task: DotNetCoreInstaller@0
displayName: 'Use .NET Core sdk 2.1.401'
inputs:
version: 2.1.401
- task: UseRubyVersion@0
inputs:
addToPath: true # Optional
- powershell: ./run.ps1 -script run.cake -target Default
displayName: 'Cake build'
- job: Windows
pool:
vmImage: 'VS2017-Win2016'
steps:
- task: DotNetCoreInstaller@0
displayName: 'Use .NET Core sdk 2.1.401'
inputs:
version: 2.1.401
- task: UseRubyVersion@0
inputs:
addToPath: true # Optional
- powershell: ./run.ps1 -script run.cake -target Default
displayName: 'Cake build'
2 changes: 1 addition & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ Task("Upload-AppVeyor-Artifacts")
Error(exception.Dump());
});

Task("Travis")
Task("Unix")
.IsDependentOn("Run-Tests");

Task("Default")
Expand Down
95 changes: 95 additions & 0 deletions build/artifacts.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
public class BuildPackages
{
public ICollection<BuildPackage> All { get; private set; }
public ICollection<BuildPackage> Nuget { get; private set; }
public ICollection<BuildPackage> Chocolatey { get; private set; }

public static BuildPackages GetPackages(
DirectoryPath nugetRooPath,
string semVersion,
string[] packageIds,
string[] chocolateyPackageIds)
{
var toNugetPackage = BuildPackage(nugetRooPath, semVersion);
var toChocolateyPackage = BuildPackage(nugetRooPath, semVersion, isChocolateyPackage: true);
var nugetPackages = packageIds.Select(toNugetPackage).ToArray();
var chocolateyPackages = chocolateyPackageIds.Select(toChocolateyPackage).ToArray();

return new BuildPackages {
All = nugetPackages.Union(chocolateyPackages).ToArray(),
Nuget = nugetPackages,
Chocolatey = chocolateyPackages
};
}

private static Func<string, BuildPackage> BuildPackage(
DirectoryPath nugetRooPath,
string semVersion,
bool isChocolateyPackage = false)
{
return package => new BuildPackage(
id: package,
nuspecPath: string.Concat("./nuspec/", package, ".nuspec"),
packagePath: nugetRooPath.CombineWithFilePath(string.Concat(package, ".", semVersion, ".nupkg")),
isChocolateyPackage: isChocolateyPackage);
}
}

public class BuildPackage
{
public string Id { get; private set; }
public FilePath NuspecPath { get; private set; }
public FilePath PackagePath { get; private set; }
public bool IsChocolateyPackage { get; private set; }
public string PackageName { get; private set; }


public BuildPackage(
string id,
FilePath nuspecPath,
FilePath packagePath,
bool isChocolateyPackage)
{
Id = id;
NuspecPath = nuspecPath;
PackagePath = packagePath;
IsChocolateyPackage = isChocolateyPackage;
PackageName = PackagePath.GetFilename().ToString();
}
}

public class BuildArtifacts
{
public ICollection<BuildArtifact> All { get; private set; }

public static BuildArtifacts GetArtifacts(FilePath[] artifacts)
{
var toBuildArtifact = BuildArtifact("build-artifact");
var buildArtifacts = artifacts.Select(toBuildArtifact).ToArray();

return new BuildArtifacts {
All = buildArtifacts.ToArray(),
};
}

private static Func<FilePath, BuildArtifact> BuildArtifact(string containerName)
{
return artifactPath => new BuildArtifact(containerName: containerName, artifactPath: artifactPath);
}
}

public class BuildArtifact
{
public string ContainerName { get; private set; }
public FilePath ArtifactPath { get; private set; }
public string ArtifactName { get; private set; }

public BuildArtifact(
string containerName,
FilePath artifactPath)
{
ContainerName = containerName;
ArtifactPath = artifactPath.FullPath;
ArtifactName = ArtifactPath.GetFilename().ToString();
}
}
Loading