Skip to content

Commit f05c7fd

Browse files
authored
Use Nerdbank.GitVersioning (#369)
- Calculate version number dynamically - Support pushing prerelease versions on NuGet - Reduce downstream maintenance efforts by fixing the version number to MAJOR.0.0.0 - Create GitHub releases for everything that's pushed to NuGet
1 parent 0a8ed37 commit f05c7fd

6 files changed

Lines changed: 66 additions & 15 deletions

File tree

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ script:
55
- dotnet build System.IO.Abstractions --framework netstandard1.4
66
- dotnet build System.IO.Abstractions.TestingHelpers --framework netstandard1.4
77
- dotnet test System.IO.Abstractions.TestingHelpers.Tests --framework netcoreapp2.0
8+
git:
9+
depth: false

CONTRIBUTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Contributor guide
2+
3+
## Versioning
4+
5+
This library uses [Nerdbank.GitVersioning](https://github.com/AArnott/Nerdbank.GitVersioning) for generating stable and reproducible version numbers.
6+
7+
The so-called base version is manually maintained in [the version config](version.json). Every build calculates its final version number based on the base version and the number of changes that occured since the last change to the version config.
8+
9+
The base version represents the _next_ version that we will released. During development it contains a prerelease suffix, like `-beta` which is appended to the generated NuGet packages.
10+
11+
Every successful commit on `master` deploys packages to `nuget.org` and a creates GitHub release. As long as we have the prelease suffix both will be marked as such.
12+
13+
### Release workflow
14+
15+
1. Remove prelease suffix from `version.json`.
16+
1. Wait for the completion of the deployment.
17+
1. Remove the prerelease flag from the newly created GitHub release.
18+
1. Increment the version number in `version.json` and again add the prelease suffix (usually `beta` is fine).

System.IO.Abstractions.TestingHelpers/System.IO.Abstractions.TestingHelpers.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<PropertyGroup>
33
<TargetFrameworks>net40;netstandard1.4;netstandard2.0;</TargetFrameworks>
44
<PackageId>System.IO.Abstractions.TestingHelpers</PackageId>
5-
<Version>0.0.0.1</Version>
65
<Description>A set of pre-built mocks to help when testing file system interactions.</Description>
76
<Company />
87
<Product>System.IO.Abstractions</Product>
@@ -36,4 +35,12 @@
3635
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="4.3.0" />
3736
<PackageReference Include="System.Security.AccessControl" Version="4.5.0" />
3837
</ItemGroup>
38+
39+
<ItemGroup>
40+
<PackageReference Include="Nerdbank.GitVersioning" Version="2.2.13">
41+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
42+
<PrivateAssets>all</PrivateAssets>
43+
</PackageReference>
44+
</ItemGroup>
45+
3946
</Project>

System.IO.Abstractions/System.IO.Abstractions.csproj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>net40;netstandard1.4;netstandard2.0;</TargetFrameworks>
5-
<Version>0.0.0.1</Version>
65
<Authors>Tatham Oddie</Authors>
76
<Company />
87
<Description>A set of abstractions to help make file system interactions testable.</Description>
@@ -11,7 +10,8 @@
1110
<PackageLicenseUrl>https://github.com/System-IO-Abstractions/System.IO.Abstractions/blob/master/LICENSE</PackageLicenseUrl>
1211
<PackageProjectUrl>https://github.com/System-IO-Abstractions/System.IO.Abstractions</PackageProjectUrl>
1312
<PackageTags>testing</PackageTags>
14-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
13+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
14+
<NoWarn>$(NoWarn);CS1591;CS1574</NoWarn>
1515
</PropertyGroup>
1616

1717
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -27,7 +27,7 @@
2727
<Version>4.5.0</Version>
2828
</PackageReference>
2929
</ItemGroup>
30-
30+
3131
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.4'">
3232
<PackageReference Include="System.IO.FileSystem.AccessControl">
3333
<Version>4.5.0</Version>
@@ -47,4 +47,12 @@
4747
<Reference Include="System" />
4848
<Reference Include="Microsoft.CSharp" />
4949
</ItemGroup>
50+
51+
<ItemGroup>
52+
<PackageReference Include="Nerdbank.GitVersioning" Version="2.2.13">
53+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
54+
<PrivateAssets>all</PrivateAssets>
55+
</PackageReference>
56+
</ItemGroup>
57+
5058
</Project>

appveyor.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,6 @@ branches:
99
only:
1010
- master
1111

12-
version: 2.1.0.{build}
13-
14-
pull_requests:
15-
do_not_increment_build_number: true
16-
17-
dotnet_csproj:
18-
patch: true
19-
file: '**\*.csproj'
20-
version: '{version}'
21-
package_version: '{version}'
22-
2312
environment:
2413
INHERITDOC_VERSION: 1.2.2.1
2514
TEMP_DIR: c:\temp
@@ -46,3 +35,14 @@ deploy:
4635
artifact: /.*\.nupkg/
4736
on:
4837
branch: master
38+
39+
- provider: GitHub
40+
tag: v$(GitBuildVersion)
41+
prerelease: true
42+
artifact: /.*\.nupkg/
43+
auth_token:
44+
secure: 4ejpp3dzvpOwfD7TOcypCsT0z8j+qYiihiZszS3uVI78vZpAtM+P+A8NK2JZmYMo
45+
on:
46+
branch: master
47+
48+

version.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3+
"version": "2.2-beta",
4+
"assemblyVersion": {
5+
"precision": "major"
6+
},
7+
"publicReleaseRefSpec": [
8+
"^refs/heads/master$"
9+
],
10+
"cloudBuild": {
11+
"buildNumber": {
12+
"enabled": true,
13+
"setVersionVariables": true
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)