Skip to content

Commit aa894ca

Browse files
committed
Documentation.
1 parent d6feffe commit aa894ca

1 file changed

Lines changed: 105 additions & 11 deletions

File tree

README.md

Lines changed: 105 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@
22
[![NuGet](https://img.shields.io/nuget/v/Subatomix.Build.Versioning.Semantic.svg)](https://www.nuget.org/packages/Subatomix.Build.Versioning.Semantic)
33
[![NuGet](https://img.shields.io/nuget/dt/Subatomix.Build.Versioning.Semantic.svg)](https://www.nuget.org/packages/Subatomix.Build.Versioning.Semantic)
44

5-
Automatic SemVer2 semantic versioning for .NET and MSBuild.
5+
Semi-automatic [SemVer2-compatible](https://semver.org/spec/v2.0.0.html)
6+
versioning for .NET and MSBuild.
7+
8+
Features:
9+
- Generates pre-release tags for Git branches, pull requests, and tags.
10+
- Verifies that release tags match their code versions.
611

712
## Status
813

9-
Nearing production release.
14+
In private use since mid-2019. Nearing public release.
1015

11-
## Usage
16+
## Requirements
17+
18+
This package makes the following assumptions:
19+
20+
- .NET [SDK-style](https://docs.microsoft.com/en-us/dotnet/core/project-sdk/overview)
21+
project system
22+
- Git source control
23+
- Releases marked with tags like `release/1.2.3-rc.1`\
24+
(the prefix `release/` followed by a valid
25+
[SemVer2](https://semver.org/spec/v2.0.0.html) version)
1226

13-
This package works with the
14-
[.NET SDK-style](https://docs.microsoft.com/en-us/dotnet/core/project-sdk/overview)
15-
project system.
27+
## Usage
1628

1729
Add a reference to this package in your project file or in a
1830
[`Directory.Build.targets`](https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build#directorybuildprops-and-directorybuildtargets)
@@ -22,22 +34,42 @@ file.
2234
<ItemGroup>
2335
<PackageReference
2436
Include="Subatomix.Build.Versioning.Semantic"
25-
Version="0.0.0-pre.7"
37+
Version="1.0.0-rc.1"
2638
PrivateAssets="All" />
2739
</ItemGroup>
2840
```
2941

3042
Set the version number in your project file or in a
3143
[`Directory.Build.props`](https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build#directorybuildprops-and-directorybuildtargets)
32-
file.
44+
file. Use the `VersionPrefix` property only.
3345

3446
```xml
3547
<PropertyGroup>
36-
<VersionPrefix>1.0.0</VersionPrefix>
48+
<VersionPrefix>1.2.3</VersionPrefix>
3749
</PropertyGroup>
3850
```
3951

40-
To communicate the generated version numbers to a build server, add one or
52+
Pass the [git refspec](https://git-scm.com/book/en/v2/Git-Internals-The-Refspec)
53+
into the build process using the `Branch` property.
54+
55+
```shell
56+
dotnet build -c Release -p:Branch=refs/heads/mybranch
57+
```
58+
59+
The build will generate a version like `1.2.3-mybranch.20201214.T154854Z` and
60+
set both the `Version` and `VersionSuffix` properties automatically. To use a
61+
custom build number instead of the default date/time-based one, pass the number
62+
to the build process using the `Counter` property.
63+
64+
```shell
65+
dotnet build -c Release -p:Branch=refs/heads/mybranch -p:Counter=4567
66+
```
67+
68+
The build will generate the version `1.2.3-mybranch.b.1234`.
69+
70+
#### Interaction With Build Servers
71+
72+
To communicate the generated version number to a build server, add one or
4173
more of the following properties to one of your project files.
4274

4375
```xml
@@ -48,4 +80,66 @@ more of the following properties to one of your project files.
4880
</PropertyGroup>
4981
```
5082

51-
More documentation is forthcoming.
83+
#### Version Stamping
84+
85+
TODO
86+
87+
## Property Reference
88+
89+
`Branch`
90+
: The full [git refspec](https://git-scm.com/book/en/v2/Git-Internals-The-Refspec)
91+
of the code being built. The behavior of this package depends primarily on
92+
the format of the refspec:
93+
94+
`Branch=refs/heads/foo`
95+
: - Recognized as a branch named `foo`.
96+
- Sets the pre-release tag to `foo` followed by a build counter.
97+
98+
`Branch=refs/heads/foo/bar`
99+
: - Recognized as a branch named `foo/bar`.
100+
- Sets the pre-release tag to `foo-bar` followed by a build counter.
101+
102+
`Branch=refs/pull/42`
103+
: - Recognized as pull request 42.
104+
- Sets the pre-release tag to `pr.42` followed by a build counter.
105+
106+
`Branch=refs/tag/release/1.2.3-foo.42`
107+
: - Recognized as a pre-release tag named `release/1.2.3-foo.42`.
108+
- Emits a build error if the `VersionPrefix` property does not match
109+
the tag version, `1.2.3`.
110+
- Sets the pre-release tag to `foo.42` followed by a build counter.
111+
112+
`Branch=refs/tag/release/1.2.3`
113+
: - Recognized as a release tag named `release/1.2.3`.
114+
- Emits a build error if the `VersionPrefix` property does not match
115+
the tag version, `1.2.3`.
116+
- **Does not** set a pre-release tag or append a build counter.
117+
118+
`Branch="something else entirely"`
119+
: - Not recognized.
120+
- Sets the pre-release tag to `something-else-entirely` followed by a
121+
build counter.
122+
123+
`Branch=""` (empty or not set)
124+
: - Sets the pre-release tag to `local`, without a build counter. This
125+
default is intended to ease local development.
126+
127+
`Counter`
128+
: An arbitrary number to distinguish the current build from other builds of
129+
the same refspec. If not set, the build generates a date/time-based
130+
counter of the form `yyyymmdd.ThhmmssZ` using the current UTC time.
131+
132+
`StampOnBuild`
133+
: TODO
134+
135+
`SetAzurePipelinesBuildName`
136+
: When `true`, the build outputs magic text that sets the name of an Azure
137+
DevOps pipeline run.
138+
139+
`SetGitHubActionsVersion`
140+
: When `true`, the build outputs magic text that sets the version of a GitHub
141+
Actions workflow run.
142+
143+
`SetTeamCityBuildNumber`
144+
: When `true`, the build outputs magic text that sets the name of a TeamCity
145+
build.

0 commit comments

Comments
 (0)