Skip to content

Commit 3c2459c

Browse files
authored
Merge pull request #1215 from JakeGinnivan/feature/docker
Feature/docker
2 parents 673bd9f + 1926031 commit 3c2459c

File tree

6 files changed

+89
-1
lines changed

6 files changed

+89
-1
lines changed

Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM gittools/libgit2sharp-mono
2+
3+
MAINTAINER GitTools Maintainers <[email protected]>
4+
ARG GitVersionZip
5+
6+
# Add GitVersion
7+
8+
ADD ./releaseArtifacts/$GitVersionZip .
9+
RUN unzip -d /usr/lib/GitVersion/ $GitVersionZip
10+
RUN rm $GitVersionZip
11+
WORKDIR /usr/lib/GitVersion/
12+
13+
# Libgit2 can't resolve relative paths, patch to absolute path
14+
RUN sed -i 's|lib/linux/x86_64|/usr/lib/GitVersion/lib/linux/x86_64|g' /usr/lib/GitVersion/LibGit2Sharp.dll.config
15+
16+
RUN mkdir /repo
17+
VOLUME /repo
18+
19+
ENTRYPOINT ["mono", "./GitVersion.exe", "/repo"]

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ works out the [semantic version][semver] of the commit being built.
1717
| **GitVersion.CommandLine** | [![NuGet][gvc-badge]][gvc] | [![NuGet][gvc-pre-badge]][gvc] |
1818
| **Gem** | [![Gem][gem-badge]][gem] | - |
1919
| **Homebrew** | [![homebrew][brew-badge]][brew] | - |
20+
| **Docker** | [gittools/gitversion][dockerhub] | - |
2021

2122
## Compatibility
2223
GitVersion works on Mac, Linux with Mono and Windows.
@@ -84,3 +85,4 @@ from The Noun Project
8485
[faq]: http://gitversion.readthedocs.org/en/latest/faq/
8586
[who]: http://gitversion.readthedocs.org/en/latest/who/
8687
[gv-in-action]: https://raw.github.com/GitTools/GitVersion/master/docs/img/README.png
88+
[dockerhub]: https://hub.docker.com/r/gittools/gitversion/

build.cake

+2-1
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ Task("Create-Release-Notes")
131131
var releaseNotesExitCode = StartProcess(
132132
@"tools\GitReleaseNotes\tools\gitreleasenotes.exe",
133133
new ProcessSettings { Arguments = ". /o build/releasenotes.md /repoToken " + githubToken });
134-
if (string.IsNullOrEmpty(System.IO.File.ReadAllText("./build/releasenotes.md")))
134+
if (!System.IO.File.Exists("./build/releasenotes.md") || string.IsNullOrEmpty(System.IO.File.ReadAllText("./build/releasenotes.md"))) {
135135
System.IO.File.WriteAllText("./build/releasenotes.md", "No issues closed since last release");
136+
}
136137

137138
if (releaseNotesExitCode != 0) throw new Exception("Failed to generate release notes");
138139
}

deploy.cake

+47
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Task("DownloadGitHubReleaseArtifacts")
7171
if (!artifactLookup.ContainsKey("NuGetExeBuild")) { throw new Exception("NuGetExeBuild artifact missing"); }
7272
if (!artifactLookup.ContainsKey("GemBuild")) { throw new Exception("GemBuild artifact missing"); }
7373
if (!artifactLookup.ContainsKey("GitVersionTfsTaskBuild")) { throw new Exception("GitVersionTfsTaskBuild artifact missing"); }
74+
if (!artifactLookup.ContainsKey("zip")) { throw new Exception("zip artifact missing"); }
7475
});
7576

7677
Task("Publish-NuGetPackage")
@@ -174,13 +175,59 @@ Task("Publish-VstsTask")
174175
}
175176
});
176177

178+
179+
Task("Publish-DockerImage")
180+
.IsDependentOn("DownloadGitHubReleaseArtifacts")
181+
.Does(() =>
182+
{
183+
var returnCode = StartProcess("docker", new ProcessSettings
184+
{
185+
Arguments = "build . --build-arg GitVersionZip=" + artifactLookup["zip"] + " --tag gittools/gitversion"
186+
});
187+
if (returnCode != 0) {
188+
Information("Publish-DockerImage Task failed to build image, but continuing with next Task...");
189+
publishingError = true;
190+
}
191+
192+
// Login to dockerhub
193+
returnCode = StartProcess("docker", new ProcessSettings
194+
{
195+
Arguments = "login -u=\"" + EnvironmentVariable("DOCKER_USERNAME") +"\" -p=\"" + EnvironmentVariable("DOCKER_PASSWORD") +"\""
196+
});
197+
if (returnCode != 0) {
198+
Information("Publish-DockerImage Task failed to login, but continuing with next Task...");
199+
publishingError = true;
200+
}
201+
202+
// Publish Tag
203+
returnCode = StartProcess("docker", new ProcessSettings
204+
{
205+
Arguments = "push gittools/gitversion:" + tag
206+
});
207+
if (returnCode != 0) {
208+
Information("Publish-DockerImage Task failed push version tag, but continuing with next Task...");
209+
publishingError = true;
210+
}
211+
212+
// Publish latest
213+
returnCode = StartProcess("docker", new ProcessSettings
214+
{
215+
Arguments = "push gittools/gitversion:latest"
216+
});
217+
if (returnCode != 0) {
218+
Information("Publish-DockerImage Task failed latest tag, but continuing with next Task...");
219+
publishingError = true;
220+
}
221+
});
222+
177223
Task("Deploy")
178224
.IsDependentOn("Publish-NuGetPackage")
179225
.IsDependentOn("Publish-NuGetCommandLine")
180226
.IsDependentOn("Publish-MsBuildTask")
181227
.IsDependentOn("Publish-Chocolatey")
182228
// .IsDependentOn("Publish-Gem")
183229
.IsDependentOn("Publish-VstsTask")
230+
.IsDependentOn("Publish-DockerImage")
184231
.Finally(() =>
185232
{
186233
if(publishingError)

src/DockerBase/Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM ubuntu
2+
3+
MAINTAINER GitTools Maintainers <[email protected]>
4+
5+
# Wheezy doesn't support glibc 2.15 which libgit2sharp requires
6+
# So we are going to install mono on ubuntu instead
7+
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
8+
RUN apt-get update
9+
RUN apt-get install libcurl3 tzdata unzip curl git-all -y
10+
RUN echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list
11+
RUN apt-get update
12+
RUN apt-get install mono-complete -y
13+
RUN cp /usr/share/zoneinfo/GMT /etc/localtime

src/DockerBase/readme

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Docker Base
2+
We need a custom docker base image because mono is too old to support libgit2sharp
3+
4+
## To build/publish
5+
docker build . --tag gittools/libgit2sharp-mono
6+
docker push gittools/libgit2sharp-mono

0 commit comments

Comments
 (0)