-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
372 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
### New in 0.0.1 (Released 2015/12/12) | ||
* First experimental release of Cake.Git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Build script | ||
build_script: | ||
- ps: .\build.ps1 -Target AppVeyor | ||
|
||
# Tests | ||
test: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
#addin "Cake.Slack" | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// ARGUMENTS | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
var target = Argument<string>("target", "Default"); | ||
var configuration = Argument<string>("configuration", "Release"); | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// GLOBAL VARIABLES | ||
/////////////////////////////////////////////////////////////////////////////// | ||
var GitHookUri = EnvironmentVariable("Githookuri"); | ||
var GitChannel = "#cake"; | ||
var isLocalBuild = !AppVeyor.IsRunningOnAppVeyor; | ||
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest; | ||
var solutions = GetFiles("./**/*.sln"); | ||
var solutionPaths = solutions.Select(solution => solution.GetDirectory()); | ||
var releaseNotes = ParseReleaseNotes("./ReleaseNotes.md"); | ||
var version = releaseNotes.Version.ToString(); | ||
var binDir = "./src/Cake.Git/bin/" + configuration; | ||
var nugetRoot = "./nuget/"; | ||
var semVersion = isLocalBuild | ||
? version | ||
: string.Concat(version, "-build-", AppVeyor.Environment.Build.Number.ToString("0000")); | ||
var assemblyInfo = new AssemblyInfoSettings { | ||
Title = "Cake.Git", | ||
Description = "Cake Git AddIn", | ||
Product = "Cake.Git", | ||
Company = "WCOM AB", | ||
Version = version, | ||
FileVersion = version, | ||
InformationalVersion = semVersion, | ||
Copyright = string.Format("Copyright © WCOM AB {0}", DateTime.Now.Year), | ||
CLSCompliant = true | ||
}; | ||
var nuGetPackSettings = new NuGetPackSettings { | ||
Id = assemblyInfo.Product, | ||
Version = assemblyInfo.InformationalVersion, | ||
Title = assemblyInfo.Title, | ||
Authors = new[] {assemblyInfo.Company}, | ||
Owners = new[] {assemblyInfo.Company}, | ||
Description = assemblyInfo.Description, | ||
Summary = "Cake AddIn that extends Cake with Git SCM features", | ||
ProjectUrl = new Uri("https://github.com/WCOMAB/Cake_Git/"), | ||
IconUrl = new Uri("http://cdn.rawgit.com/WCOMAB/nugetpackages/master/Chocolatey/icons/wcom.png"), | ||
LicenseUrl = new Uri("https://github.com/WCOMAB/Cake.Git/blob/master/LICENSE"), | ||
Copyright = assemblyInfo.Copyright, | ||
ReleaseNotes = releaseNotes.Notes.ToArray(), | ||
Tags = new [] {"Cake", "Script", "Build", "Git"}, | ||
RequireLicenseAcceptance= false, | ||
Symbols = false, | ||
NoPackageAnalysis = true, | ||
Files = new [] { | ||
new NuSpecContent {Source = "Cake.Git.dll"}, | ||
new NuSpecContent {Source = "Cake.Git.pdb"}, | ||
new NuSpecContent {Source = "Cake.Git.xml"}, | ||
new NuSpecContent {Source = "LibGit2Sharp.dll"}, | ||
new NuSpecContent {Source = "LibGit2Sharp.pdb"}, | ||
new NuSpecContent {Source = "LibGit2Sharp.xml"}, | ||
new NuSpecContent {Source = "NativeBinaries/amd64/git2-821131f.dll", Target = "NativeBinaries/amd64/git2-821131f.dll"}, | ||
new NuSpecContent {Source = "NativeBinaries/amd64/git2-821131f.pdb", Target = "NativeBinaries/amd64/git2-821131f.pdb"}, | ||
new NuSpecContent {Source = "NativeBinaries/linux/amd64/libgit2-821131f.so", Target = "NativeBinaries/linux/amd64/libgit2-821131f.so"}, | ||
new NuSpecContent {Source = "NativeBinaries/osx/libgit2-821131f.dylib", Target = "NativeBinaries/osx/libgit2-821131f.dylib"}, | ||
new NuSpecContent {Source = "NativeBinaries/x86/git2-821131f.dll", Target = "NativeBinaries/x86/git2-821131f.dll"}, | ||
new NuSpecContent {Source = "NativeBinaries/x86/git2-821131f.pdb", Target = "NativeBinaries/x86/git2-821131f.pdb"}, | ||
}, | ||
BasePath = binDir, | ||
OutputDirectory = nugetRoot | ||
}; | ||
|
||
if (!isLocalBuild) | ||
{ | ||
AppVeyor.UpdateBuildVersion(semVersion); | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// SETUP / TEARDOWN | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
Setup(() => | ||
{ | ||
// Executed BEFORE the first task. | ||
Information("Running tasks..."); | ||
|
||
var buildStartMessage = string.Format( | ||
"Building version {0} of {1} ({2}).", | ||
version, | ||
assemblyInfo.Product, | ||
semVersion | ||
); | ||
|
||
Information(buildStartMessage); | ||
if(!string.IsNullOrEmpty(GitHookUri)) | ||
{ | ||
Slack.Chat.PostMessage( | ||
channel:GitChannel, | ||
text:buildStartMessage, | ||
messageSettings:new SlackChatMessageSettings { IncomingWebHookUrl = GitHookUri } | ||
); | ||
} | ||
}); | ||
|
||
Teardown(() => | ||
{ | ||
// Executed AFTER the last task. | ||
Information("Finished running tasks."); | ||
}); | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// TASK DEFINITIONS | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Clean") | ||
.Does(() => | ||
{ | ||
// Clean solution directories. | ||
foreach(var path in solutionPaths) | ||
{ | ||
Information("Cleaning {0}", path); | ||
CleanDirectories(path + "/**/bin/" + configuration); | ||
CleanDirectories(path + "/**/obj/" + configuration); | ||
} | ||
}); | ||
|
||
Task("Restore") | ||
.Does(() => | ||
{ | ||
// Restore all NuGet packages. | ||
foreach(var solution in solutions) | ||
{ | ||
Information("Restoring {0}...", solution); | ||
NuGetRestore(solution); | ||
} | ||
}); | ||
|
||
Task("SolutionInfo") | ||
.IsDependentOn("Clean") | ||
.IsDependentOn("Restore") | ||
.Does(() => | ||
{ | ||
var file = "./src/SolutionInfo.cs"; | ||
CreateAssemblyInfo(file, assemblyInfo); | ||
}); | ||
|
||
Task("Build") | ||
.IsDependentOn("Clean") | ||
.IsDependentOn("Restore") | ||
.IsDependentOn("SolutionInfo") | ||
.Does(() => | ||
{ | ||
// Build all solutions. | ||
foreach(var solution in solutions) | ||
{ | ||
Information("Building {0}", solution); | ||
MSBuild(solution, settings => | ||
settings.SetPlatformTarget(PlatformTarget.MSIL) | ||
.WithProperty("TreatWarningsAsErrors","true") | ||
.WithTarget("Build") | ||
.SetConfiguration(configuration)); | ||
} | ||
}); | ||
|
||
|
||
Task("Create-NuGet-Package") | ||
.IsDependentOn("Build") | ||
.Does(() => | ||
{ | ||
if (!DirectoryExists(nugetRoot)) | ||
{ | ||
CreateDirectory(nugetRoot); | ||
} | ||
NuGetPack(nuGetPackSettings); | ||
}); | ||
|
||
Task("Publish-MyGet") | ||
.IsDependentOn("Create-NuGet-Package") | ||
.WithCriteria(() => !isLocalBuild) | ||
.WithCriteria(() => !isPullRequest) | ||
.Does(() => | ||
{ | ||
// Resolve the API key. | ||
var apiKey = EnvironmentVariable("MYGET_API_KEY"); | ||
if(string.IsNullOrEmpty(apiKey)) { | ||
throw new InvalidOperationException("Could not resolve MyGet API key."); | ||
} | ||
|
||
var source = EnvironmentVariable("MYGET_SOURCE"); | ||
if(string.IsNullOrEmpty(apiKey)) { | ||
throw new InvalidOperationException("Could not resolve MyGet source."); | ||
} | ||
|
||
// Get the path to the package. | ||
var package = nugetRoot + "Cake.Git." + semVersion + ".nupkg"; | ||
|
||
// Push the package. | ||
NuGetPush(package, new NuGetPushSettings { | ||
Source = source, | ||
ApiKey = apiKey | ||
}); | ||
}); | ||
|
||
|
||
Task("Default") | ||
.IsDependentOn("Create-NuGet-Package"); | ||
|
||
Task("AppVeyor") | ||
.IsDependentOn("Publish-MyGet"); | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// EXECUTION | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
RunTarget(target); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<# | ||
.SYNOPSIS | ||
This is a Powershell script to bootstrap a Cake build. | ||
.DESCRIPTION | ||
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) | ||
and execute your Cake build script with the parameters you provide. | ||
.PARAMETER Script | ||
The build script to execute. | ||
.PARAMETER Target | ||
The build script target to run. | ||
.PARAMETER Configuration | ||
The build configuration to use. | ||
.PARAMETER Verbosity | ||
Specifies the amount of information to be displayed. | ||
.PARAMETER WhatIf | ||
Performs a dry run of the build script. | ||
No tasks will be executed. | ||
.PARAMETER Experimental | ||
Tells Cake to use the latest Roslyn release. | ||
.LINK | ||
http://cakebuild.net | ||
#> | ||
|
||
Param( | ||
[string]$Script = "build.cake", | ||
[string]$Target = "Default", | ||
[string]$Configuration = "Release", | ||
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] | ||
[string]$Verbosity = "Verbose", | ||
[Alias("DryRun","Noop")] | ||
[switch]$Experimental, | ||
[switch]$WhatIf | ||
) | ||
|
||
$TOOLS_DIR = Join-Path $PSScriptRoot "tools" | ||
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" | ||
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" | ||
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" | ||
|
||
# Should we use the new Roslyn? | ||
$UseExperimental = ""; | ||
if($Experimental.IsPresent) { | ||
$UseExperimental = "-experimental" | ||
} | ||
|
||
# Is this a dry run? | ||
$UseDryRun = ""; | ||
if($WhatIf.IsPresent) { | ||
$UseDryRun = "-dryrun" | ||
} | ||
|
||
# Make sure tools folder exists | ||
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { | ||
New-Item -path $TOOLS_DIR -name logfiles -itemtype directory | ||
} | ||
|
||
# Try find NuGet.exe in path if not exists | ||
if (!(Test-Path $NUGET_EXE)) { | ||
"Trying to find nuget.exe in path" | ||
$NUGET_EXE_IN_PATH = &where.exe nuget.exe | ||
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH)) { | ||
"Found $($NUGET_EXE_IN_PATH)" | ||
$NUGET_EXE = $NUGET_EXE_IN_PATH | ||
} | ||
} | ||
|
||
# Try download NuGet.exe if not exists | ||
if (!(Test-Path $NUGET_EXE)) { | ||
Invoke-WebRequest -Uri http://nuget.org/nuget.exe -OutFile $NUGET_EXE | ||
} | ||
|
||
# Make sure NuGet exists where we expect it. | ||
if (!(Test-Path $NUGET_EXE)) { | ||
Throw "Could not find NuGet.exe" | ||
} | ||
|
||
# Save nuget.exe path to environment to be available to child processed | ||
$ENV:NUGET_EXE = $NUGET_EXE | ||
|
||
# Restore tools from NuGet. | ||
Push-Location | ||
Set-Location $TOOLS_DIR | ||
|
||
# Restore packages | ||
if (Test-Path $PACKAGES_CONFIG) | ||
{ | ||
Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion" | ||
} | ||
# Install just Cake if missing config | ||
else | ||
{ | ||
Invoke-Expression "&`"$NUGET_EXE`" install Cake -ExcludeVersion -PreRelease -Source `"https://www.myget.org/F/cake`"" | ||
} | ||
Pop-Location | ||
if ($LASTEXITCODE -ne 0) | ||
{ | ||
exit $LASTEXITCODE | ||
} | ||
|
||
# Make sure that Cake has been installed. | ||
if (!(Test-Path $CAKE_EXE)) { | ||
Throw "Could not find Cake.exe" | ||
} | ||
|
||
# Start Cake | ||
Invoke-Expression "$CAKE_EXE `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseDryRun $UseExperimental" | ||
exit $LASTEXITCODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.