Permalink
Browse files

Implement continuous integration

As a first step for continuous integration I implemented some build
scripts based on fake, which should be executed on appveyor.

The build does the following:
 - Install dependencies for the build with paket
 - Install nuget dependenices of the Solution
 - Get the version with GitVersion and path AssemblyInfo
 - Build
 - Pack nuget package
  • Loading branch information...
1 parent 488e276 commit b4256834d931bafe769f849513d18a37355b4b3e @yannisgu yannisgu committed Oct 30, 2014
View
@@ -21,7 +21,6 @@ PublishProfiles/*
[Dd]ebugPublic/
[Rr]elease/
x64/
-build/
bld/
[Bb]in/
[Oo]bj/
@@ -185,4 +184,8 @@ UpgradeLog*.htm
FakesAssemblies/
# Roslyn
-*.sln.ide
+*.sln.ide
+
+build/paket.exe
+tools
+*.nupkg
View
@@ -0,0 +1,19 @@
+version: 0.{build}
+
+branches:
+ # blacklist
+ except:
+ - gh-pages
+
+build_script:
+ - ps: ./build.ps1
+
+artifacts:
+ - path: '*.nupkg'
+ - path: src/SourceBrowser.Samples/bin/Release
+ name: SourceBrowser.Samples
+ type: zip
+
+environment:
+ NUGET_APIKEY:
+ secure: VSjE99jnuR+cp3tbjyRxs9wZdZz2B7AShz0/c8tq43oUGUl0SJ5jXFzv7VyZyS3b
View
@@ -0,0 +1,24 @@
+$buildFolder = "$PSScriptRoot\build"
+$toolsFolder = "$PSScriptRoot\tools"
+$nuget = "$toolsFolder\nuget.exe"
+& "$buildFolder\paket.bootstrapper.exe"
+Push-Location $buildFolder
+& "$buildFolder\paket.exe" restore
+Pop-Location
+
+if(-not (Test-Path $toolsFolder)) {
+ mkdir $toolsFolder | Out-Null
+}
+
+if(-not (Test-Path $nuget)) {
+ Invoke-WebRequest "https://nuget.org/nuget.exe" -OutFile $nuget
+}
+
+$fake = "$buildFolder\packages\FAKE\tools\Fake.exe"
+
+& $fake "$buildFolder\build.fsx"
+if($LASTEXITCODE -ne 0) {
+ if($env:APPVEYOR) {
+ exit 1
+ }
+}
View
@@ -0,0 +1,118 @@
+#r "packages/FAKE/tools/FakeLib.dll" // include Fake lib
+#r "packages/GitVersion/Lib/Net45/GitVersionCore.dll"
+#r "packages/LibGit2Sharp/lib/net40/LibGit2Sharp.dll"
+open GitVersion
+open Fake
+open Fake.NuGet.Install
+open System.Collections.Generic
+open System
+
+#load "helpers.fsx"
+open Helpers
+
+let solution = ("../src/SourceBrowser.sln" |> FullNameFromHere)
+
+let mutable semanticVersion : SemanticVersion = null
+let mutable semanticVersionVariables : Dictionary<string, string> = null
+let mutable nugetVersion : string = ""
+
+
+Target "Restore" (fun _ ->
+ CustomRestorePackage solution
+)
+
+
+Target "Build" (fun _ ->
+ let buildMode = getBuildParamOrDefault "buildMode" "Release"
+
+ let setParams defaults =
+ { defaults with
+ Verbosity = Some(MSBuildVerbosity.Normal)
+ Targets = ["Build"]
+ Properties =
+ [
+ "Configuration", buildMode
+ ]
+ }
+
+ build setParams solution
+)
+
+Target "Versioning" (fun _ ->
+
+ let log (s :string) = System.Console.WriteLine(s)
+ let action = (System.Action<string> log)
+
+ GitVersion.Logger.WriteInfo <- action
+ GitVersion.Logger.WriteWarning <- action
+ GitVersion.Logger.WriteError <- action
+ let dir = (".." |> FullNameFromHere)
+ let repo =
+ RepositoryLoader.GetRepo(dir)
+
+
+ let servers = GitVersion.BuildServerList.GetApplicableBuildServers(GitVersion.Authentication())
+
+ for server in servers do
+ server.PerformPreProcessingSteps (dir) |> ignore
+
+
+ semanticVersion <- GitVersionFinder.GetSemanticVersion(repo)
+
+ for server in servers do
+ server.WriteIntegration(semanticVersion, action) |> ignore
+
+ semanticVersionVariables <- VariableProvider.GetVariablesFor(semanticVersion)
+
+ BulkReplaceAssemblyInfoVersions (".." |> FullNameFromHere) (fun f ->
+ {f with
+ AssemblyVersion = semanticVersionVariables.["AssemblySemVer"]
+ AssemblyFileVersion = semanticVersionVariables.["AssemblySemVer"]
+ AssemblyInformationalVersion = semanticVersionVariables.["SemVer"]
+ })
+
+)
+
+Target "Pack" (fun _ ->
+ nugetVersion <- (sprintf "%s-beta"semanticVersionVariables.["NuGetVersionV2"])
+ CusomtNuGetPack ("../src/SourceBrowser.Generator/SourceBrowser.Generator.csproj" |> FullNameFromHere) nugetVersion "Release"
+)
+
+Target "Test" (fun _ ->
+ trace "test stuff..."
+
+)
+
+Target "Publish" (fun _ ->
+ let setParams (defaults : NuGetParams) =
+ { defaults with
+ AccessKey = environVar "NUGET_APIKEY"
+ OutputPath = (".." |> FullNameFromHere)
+ WorkingDir = (".." |> FullNameFromHere)
+ Project = "SourceBrowser.Generator"
+ Version = nugetVersion
+ }
+
+ NuGetPublish setParams
+)
+
+
+"Build"
+ ==> "Test"
+
+"Restore"
+ ==> "Build"
+
+"Versioning"
+ ==> "Build"
+
+"Build"
+ ==> "Pack"
+
+"Pack"
+ ==> "Publish"
+
+if((environVar "APPVEYOR_REPO_TAG") = "True") then
+ Run "Publish"
+else
+ Run "Pack"
View
@@ -0,0 +1,35 @@
+module Helpers
+
+#r "packages/FAKE/tools/FakeLib.dll" // include Fake lib
+open Fake
+open System
+
+
+let inline FullNameFromHere (fileName : string) = (__SOURCE_DIRECTORY__ + "/" + fileName)
+
+let CustomRestorePackage solution =
+ traceStartTask "CustomRestorePackage" solution
+ let (parameters:RestorePackageParams) = RestorePackageDefaults
+
+
+ let args =" \"restore\" \"" + (solution |> FullName) + "\""
+
+ runNuGetTrial parameters.Retries parameters.ToolPath parameters.TimeOut args (fun () -> failwithf "Package restore of %s failed." solution)
+ traceEndTask "CustomRestorePackage" solution
+
+let CusomtNuGetPack nuspecOrProject version configuration =
+ traceStartTask "CusomtNuGetPack" nuspecOrProject
+
+ let toolPath = findNuget (currentDirectory @@ "tools" @@ "NuGet")
+
+ let args = String.concat " " ["pack"; nuspecOrProject; "-version"; version; "-p"; (sprintf "Configuration=%s" configuration) ]
+
+ let result =
+ ExecProcess (fun info ->
+ info.FileName <- toolPath
+ info.WorkingDirectory <- (".." |> FullNameFromHere)
+ info.Arguments <- args) (TimeSpan.FromMinutes 5.)
+
+ if result <> 0 then failwithf "Error during NuGet package creation. %s %s" toolPath args
+
+ traceEndTask "CusomtNuGetPack" nuspecOrProject
Binary file not shown.
@@ -0,0 +1,5 @@
+source https://nuget.org/api/v2
+
+nuget FAKE
+nuget GitVersion
+nuget LibGit2Sharp
View
@@ -0,0 +1,6 @@
+NUGET
+ remote: https://nuget.org/api/v2
+ specs:
+ FAKE (3.7.9)
+ GitVersion (1.3.2)
+ LibGit2Sharp (0.19.0.0)
@@ -98,16 +98,17 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
+ <None Include="SourceBrowser.Generator.nuspec" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<package >
+ <metadata>
+ <id>$id$</id>
+ <version>$version$</version>
+ <title>SourceBrowser - Generator</title>
+ <authors>CodeConnect</authors>
+ <owners>JoshVarty, AmadeusW, yannisgu</owners>
+ <licenseUrl>https://github.com/CodeConnect/SourceBrowser</licenseUrl>
+ <projectUrl>https://github.com/CodeConnect/SourceBrowser</projectUrl>
+ <iconUrl>https://avatars1.githubusercontent.com/u/9244729?v=2&amp;s=200</iconUrl>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <description>SourceBrowser - Generator</description>
+ <copyright>Copyright 2014</copyright>
+ </metadata>
+</package>

0 comments on commit b425683

Please sign in to comment.