Skip to content

Commit 135dd6f

Browse files
author
Jos Hickson
committed
Added means of versioning via targets file.
Added top-level build script.
1 parent 712a632 commit 135dd6f

9 files changed

Lines changed: 177 additions & 10 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
!*.json
1616
!*.md
1717
!*.snk
18+
!*.bat
19+
!*.sh
1820
bin/
1921
obj/
20-
project.lock.json
2122
/.vs/
2223
/.vscode/
24+
Version.targets

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ To build from Visual Studio you'll need VS 2017.
5353
Assuming you have the .NET Core build tools installed, building the library from the command-line just involves:
5454

5555
```
56+
dotnet restore
5657
dotnet build
5758
```
5859

Winton.Extensions.Threading.Actor.Tests.Utilities/Winton.Extensions.Threading.Actor.Tests.Utilities.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,8 @@
4040
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
4141
</ItemGroup>
4242

43+
<ItemGroup>
44+
<Folder Include="Properties\" />
45+
</ItemGroup>
46+
4347
</Project>

Winton.Extensions.Threading.Actor/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
// Copyright (c) Winton. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENCE in the project root for license information.
33

4-
using System.Reflection;
54
using System.Runtime.CompilerServices;
65

7-
[assembly: AssemblyCompany("Winton")]
8-
[assembly: AssemblyProduct("Winton.Extensions.Threading.Actor")]
9-
[assembly: AssemblyVersion("1.0.0.0")]
10-
116
[assembly: InternalsVisibleTo("Winton.Extensions.Threading.Actor.Tests.Unit, PublicKey=" +
127
"0024000004800000940000000602000000240000525341310004000001000100416865b73b600c" +
138
"858e955fc3ecd8839101f36325deca8484e83dce39491252673e5894b1e7d9f1062fb9db89c078" +
149
"2eea46d047b845fbfd93e90f2cc0f04bfbcdbda5322846e97314329207b538294b579c52fb67e5" +
1510
"d28a647c197fcd823d41746b307c82cae4edb9630ef62fbc17c4d725f8119a899236d4ebf13e48" +
1611
"9f5c8fa9")]
17-
assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=" +
12+
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=" +
1813
"0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99" +
1914
"c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654" +
2015
"753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46" +

Winton.Extensions.Threading.Actor/Winton.Extensions.Threading.Actor.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3+
<Import Condition="Exists('../Version.targets')" Project="../Version.targets" />
4+
35
<PropertyGroup>
46
<Copyright>Copyright © 2017 Winton</Copyright>
57
<Authors>Jos Hickson</Authors>
@@ -18,11 +20,11 @@
1820
<RepositoryType>git</RepositoryType>
1921
<RepositoryUrl>https://github.com/wintoncode/Winton.Extensions.Threading.Actor.git</RepositoryUrl>
2022
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.3' ">1.6.1</NetStandardImplicitPackageVersion>
21-
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
22-
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
23-
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
23+
<GenerateAssemblyCompanyAttribute>true</GenerateAssemblyCompanyAttribute>
24+
<GenerateAssemblyProductAttribute>true</GenerateAssemblyProductAttribute>
2425
<DelaySign>False</DelaySign>
2526
<Description>An implementation of an actor designed to integrate with C#'s async/await.</Description>
27+
<Company>Winton</Company>
2628
</PropertyGroup>
2729

2830
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">

build.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) Winton. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0. See LICENCE in the project root for license information.
5+
6+
set -euo pipefail;
7+
8+
VERSION_AND_PUBLISH="false";
9+
10+
while getopts v option;
11+
do
12+
case "${option}"
13+
in
14+
v) VERSION_AND_PUBLISH="true";;
15+
esac
16+
done;
17+
18+
echo "Cleaning ..."
19+
dotnet clean
20+
echo
21+
22+
echo "Restoring ..."
23+
dotnet restore
24+
echo
25+
26+
if [[ "$VERSION_AND_PUBLISH" == "true" ]]; then
27+
echo "Versioning ..."
28+
(cd etc/scripts && ./write_version_targets.sh)
29+
echo
30+
else
31+
echo "WARN: Skipping versioning."
32+
echo
33+
fi
34+
35+
echo "Building ..."
36+
dotnet build --configuration Release
37+
echo
38+
39+
echo "Testing ..."
40+
(cd Winton.Extensions.Threading.Actor.Tests.Unit && dotnet test --no-build --configuration Release)
41+
echo
42+
43+
if [[ "$VERSION_AND_PUBLISH" == "true" ]]; then
44+
echo "Packing ..."
45+
(cd Winton.Extensions.Threading.Actor && dotnet pack --no-build --configuration Release)
46+
fi
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) Winton. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0. See LICENCE in the project root for license information.
5+
6+
set -euo pipefail
7+
8+
GIT=$(which git)
9+
10+
# Outputs to stdout the the assembly version in the form major.0.0.0.
11+
# If no version is passed in then one is determined using git describe --tags
12+
13+
desc_cmd="$GIT describe --tags";
14+
15+
case "$#" in
16+
1)
17+
desc="$1";
18+
;;
19+
0)
20+
desc="$($desc_cmd)";
21+
;;
22+
*)
23+
echo "Usage: $0 [<version>]";
24+
exit 1;
25+
esac;
26+
27+
major="${desc%%.*}";
28+
29+
echo "$major.0.0.0";
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) Winton. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0. See LICENCE in the project root for license information.
5+
6+
set -euo pipefail
7+
8+
GIT=$(which git)
9+
10+
# Tries to determines a version similar to that output by GitVersion
11+
12+
# If a tag is checked out or we're bang on a tag anyway then getting the exact match
13+
# will set branch to the version number. This will mean that below the branch is
14+
# treated as a release no matter what the true name of the branch is.
15+
branch="$($GIT describe --tags --exact-match --match='[0-9]*.[0-9]*.[0-9]*' 2>/dev/null || $GIT symbolic-ref -q --short HEAD)";
16+
desc="$($GIT describe --tags --long --match='[0-9]*.[0-9]*.[0-9]*' 2>/dev/null || echo '0.0.0-0')";
17+
current_version="${desc%%-*}";
18+
branch_type="${branch%/*}";
19+
branch_short_name="${branch#*/}";
20+
21+
if [ "$branch_type" = "$current_version" ]; then
22+
branch_type="release";
23+
fi;
24+
25+
major="${current_version%%.*}";
26+
minor="${current_version%.*}";
27+
minor="${minor#*.}";
28+
patch="${current_version##*.}";
29+
hops="${desc#$current_version-}";
30+
hops="${hops%%-*}";
31+
32+
if [ "$branch_type" == "patch" ]; then
33+
patch=$((patch + 1));
34+
else
35+
if [ "$branch_type" != "release" ]; then
36+
minor=$((minor + 1));
37+
patch="0";
38+
else
39+
if [ "$hops" != "0" ]; then
40+
patch=$((patch + 1));
41+
fi;
42+
fi;
43+
fi;
44+
45+
if [ "$branch_type" != "release" ]; then
46+
prerelease="-$branch_short_name-$hops";
47+
else
48+
if [ "$hops" != "0" ]; then
49+
prerelease="-RC$hops";
50+
else
51+
prerelease="";
52+
fi;
53+
fi;
54+
55+
echo "$major.$minor.$patch$prerelease";
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) Winton. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0. See LICENCE in the project root for license information.
5+
6+
set -euo pipefail
7+
8+
# Get where this script is (thanks StackOverflow! http://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within)
9+
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10+
version_targets=$script_dir/../../Version.targets
11+
12+
file_version=$($script_dir/calculate_file_version.sh)
13+
assembly_version=$($script_dir/calculate_assembly_version.sh $file_version)
14+
version_prefix=${file_version%%-*}
15+
version_suffix=${file_version#*-}
16+
17+
cat > $version_targets <<EOF
18+
<!--
19+
THIS FILE IS AUTO-GENERATED BY TOOL AND COULD BE OVERWRITTEN AT ANY TIME.
20+
-->
21+
<Project>
22+
<PropertyGroup>
23+
<AssemblyVersion>$assembly_version</AssemblyVersion>
24+
<VersionPrefix>$version_prefix</VersionPrefix>
25+
<VersionSuffix>$version_suffix</VersionSuffix>
26+
<GenerateAssemblyVersionAttribute>true</GenerateAssemblyVersionAttribute>
27+
</PropertyGroup>
28+
</Project>
29+
EOF
30+
31+
echo "Assembly version: $assembly_version"
32+
echo "Version prefix : $version_prefix"
33+
echo "Version suffix : $version_suffix"

0 commit comments

Comments
 (0)