Skip to content

Commit 1d7bdfa

Browse files
authored
Merge pull request #4096 from arturcic/feat/4078
#4078 - update dockerhub README info
2 parents be9ccda + 786a159 commit 1d7bdfa

File tree

4 files changed

+58
-16
lines changed

4 files changed

+58
-16
lines changed

build/common/Utilities/DockerContextExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private static IEnumerable<string> GetDockerTags(this BuildContextBase context,
202202
var distro = dockerImage.Distro;
203203
var targetFramework = dockerImage.TargetFramework;
204204

205-
if (context.Version == null) return Enumerable.Empty<string>();
205+
if (context.Version == null) return [];
206206
var tags = new List<string>
207207
{
208208
$"{name}:{context.Version.Version}-{distro}-{targetFramework}",
@@ -211,12 +211,13 @@ private static IEnumerable<string> GetDockerTags(this BuildContextBase context,
211211

212212
if (distro == Constants.DockerDistroLatest && targetFramework == Constants.VersionLatest)
213213
{
214-
tags.AddRange(new[] { $"{name}:{context.Version.Version}", $"{name}:{context.Version.SemVersion}", });
214+
tags.Add($"{name}:{context.Version.SemVersion}");
215215

216216
if (context.IsStableRelease)
217217
{
218218
tags.AddRange(
219219
[
220+
$"{name}:{context.Version.Version}",
220221
$"{name}:latest",
221222
$"{name}:latest-{targetFramework}",
222223
$"{name}:latest-{distro}",

build/common/Utilities/Models.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static BuildVersion Calculate(GitVersion gitVersion)
4040
nugetVersion += $".{gitVersion.BuildMetaData}";
4141
}
4242

43-
return new BuildVersion(
43+
return new(
4444
GitVersion: gitVersion,
4545
Version: version,
4646
Milestone: semVersion,

build/docker/Tasks/DockerHubReadmePublish.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ private static string GetReadmeContent(BuildContextBase context)
5555
// language=markdown
5656
var readme = $"""
5757
# GitVersion
58+
5859
![GitVersion – From git log to SemVer in no time][banner]
5960
6061
Versioning when using Git, solved. GitVersion looks at your git history and works out the [Semantic Version][semver] of the commit being built.
@@ -63,18 +64,35 @@ private static string GetReadmeContent(BuildContextBase context)
6364
6465
## Usage
6566
66-
The recommended image to run is `alpine`, as they are the smallest Docker images we provide (83 MB). This will execute GitVersion for the current working directory (`$(pwd)`) on Linux and Unix or powershell on Windows:
67+
The recommended image to run is `alpine`, as they are the smallest Docker images we provide. This will execute GitVersion for the current working directory (`$(pwd)`) on Linux and Unix or powershell on Windows:
6768
6869
```sh
6970
docker run --rm -v "$(pwd):/repo" gittools/gitversion:{tag} /repo
7071
```
72+
7173
The following command will execute GitVersion for the current working directory (`%CD%`) on Windows with CMD:
7274
7375
```sh
7476
docker run --rm -v "%CD%:/repo" gittools/gitversion:{tag} /repo
7577
```
78+
7679
Note that the path `/repo` needs to be passed as an argument since the `gitversion` executable within the container is not aware of the fact that it's running inside a container.
7780
81+
### CI Agents
82+
83+
If you are running GitVersion on a CI agent, you may need to specify environment variables to allow GitVersion to work correctly.
84+
For example, on Azure DevOps you may need to set the following environment variables:
85+
86+
```sh
87+
docker run --rm -v "$(pwd):/repo" --env TF_BUILD=true --env BUILD_SOURCEBRANCH=$(Build.SourceBranch) gittools/gitversion:{tag} /repo
88+
```
89+
90+
On GitHub Actions, you may need to set the following environment variables:
91+
92+
```sh
93+
docker run --rm -v "$(pwd):/repo" --env GITHUB_ACTIONS=true --env GITHUB_REF=$(GITHUB_REF) gittools/gitversion:{tag} /repo
94+
```
95+
7896
### Tags
7997
8098
Most of the tags we provide have both arm64 and amd64 variants. If you need to pull a architecture specific tag you can do that like:

docs/input/docs/usage/docker.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,45 @@ Description: |
55
Use GitVersion through one of its many published Docker containers.
66
---
77

8-
GitVersion can be used through one of its many published Docker
9-
containers. The list of available containers can be found on
10-
[Docker Hub][docker-hub]. Once you've found the image you want to use,
11-
you can run it like this:
8+
The recommended image to run is `alpine`, as they are the smallest Docker images we provide. This will execute GitVersion for the current working directory (`$(pwd)`) on Linux and Unix or powershell on Windows:
129

13-
```shell
14-
docker run --rm --volume "$(pwd):/repo" gittools/gitversion:6.0.0-fedora.36-6.0 /repo
10+
```sh
11+
docker run --rm -v "$(pwd):/repo" gittools/gitversion:{tag} /repo
1512
```
1613

17-
The above command will run GitVersion with the current directory
18-
mapped to `/repo` inside the container (the `--volume "$(pwd):/repo"`
19-
part). The `/repo` directory is then passed in as the argument
20-
GitVersion should use to calculate the version.
14+
The following command will execute GitVersion for the current working directory (`%CD%`) on Windows with CMD:
2115

22-
The `--rm` flag will remove the container after it has finished
23-
running.
16+
```sh
17+
docker run --rm -v "%CD%:/repo" gittools/gitversion:{tag} /repo
18+
```
19+
20+
Note that the path `/repo` needs to be passed as an argument since the `gitversion` executable within the container is not aware of the fact that it's running inside a container.
21+
22+
### CI Agents
23+
24+
If you are running GitVersion on a CI agent, you may need to specify environment variables to allow GitVersion to work correctly.
25+
For example, on Azure DevOps you may need to set the following environment variables:
26+
27+
```sh
28+
docker run --rm -v "$(pwd):/repo" --env TF_BUILD=true --env BUILD_SOURCEBRANCH=$(Build.SourceBranch) gittools/gitversion:{tag} /repo
29+
```
30+
31+
On GitHub Actions, you may need to set the following environment variables:
32+
33+
```sh
34+
docker run --rm -v "$(pwd):/repo" --env GITHUB_ACTIONS=true --env GITHUB_REF=$(GITHUB_REF) gittools/gitversion:{tag} /repo
35+
```
36+
37+
### Tags
38+
39+
Most of the tags we provide have both arm64 and amd64 variants. If you need to pull a architecture specific tag you can do that like:
40+
41+
```sh
42+
docker run --rm -v "$(pwd):/repo" gittools/gitversion:{tag}-amd64 /repo
43+
docker run --rm -v "$(pwd):/repo" gittools/gitversion:{tag}-arm64 /repo
44+
```
45+
46+
The list of available containers can be found on [Docker Hub][docker-hub].
2447

2548
[Explore GitVersion on Docker Hub][docker-hub]{.btn .btn-primary}
2649

0 commit comments

Comments
 (0)