Skip to content

Commit 04c0e59

Browse files
committed
package version logic
1 parent 5d3bb75 commit 04c0e59

5 files changed

Lines changed: 92 additions & 50 deletions

File tree

How-to-release.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
- Bump the version number in Rubjerg.Graphviz.csproj to the version to be released.
2-
- Do a Release build. You can use the `build-release.sh` script for this.
3-
- Upload the generated .nupkg file to nuget.org.
4-
- Located at Rubjerg.Graphviz\bin\x64\Release\Rubjerg.Graphviz.x.y.z.nupkg
2+
- Make a PR and grab the nuget package from the CI artifacts.
3+
- Upload the .nupkg file to nuget.org.
54
- Upload to https://www.nuget.org/packages/manage/upload
65
- Make a cup of coffee
76
- Update the version of the referenced Nuget package in the NugetOrgTest project to the package that was just uploaded and run the test.
87
- dotnet add Rubjerg.Graphviz.NugetOrgTest\Rubjerg.Graphviz.NugetOrgTest.csproj package Rubjerg.Graphviz
9-
- If the build and test succeeds we are ready to release. Commit the changes, add the tag, and push this to github.
10-
- git commit -am 'Release vx.y.z'
8+
- If the build and test succeeds we are ready to release. Merge the PR, add the tag, and push this to github.
9+
- Merge PR on github
1110
- git tag vx.y.z
1211
- git push github --tags
1312
- In GitHub, add a new release of the just pushed commit at https://github.com/Rubjerg/Graphviz.NetWrapper/releases.

How-to-upgrade-graphviz.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Now on linux (e.g. WSL)
2525
- Download the Fedora package (e.g. fedora_41_graphviz-<version>-cmake.rpm) into the current working directory
2626
- Run `bash unpack-rpm.sh fedora_41_graphviz-<version>-cmake.rpm` to deploy the files to the linux subfolder
2727
- Run `bash patch-rpath.sh linux/` to patch the RPATH of all binaries so they can find the locally deployed version of graphviz.
28-
- Make sure none of the include files have changed (as a sanity check this is the same version as on windows)
28+
- Make sure none of the include files have changed (as a sanity check that this is the same version as on windows)
2929

3030
- Compile and run the tests
3131
- Update version number in README-src.md and run `bash generatereadme.sh`
Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,17 @@
1-
using System.Linq;
21
using NUnit.Framework;
2+
using Rubjerg.Graphviz.Test;
33

44
namespace Rubjerg.Graphviz.NugetOrgTest
55
{
66
[TestFixture()]
7-
public class TestNugetPackage
7+
public class TestNugetPackageTransitive
88
{
99
[Test()]
10-
public void TestReadDotFile()
10+
public void Test()
1111
{
12-
RootGraph root = RootGraph.FromDotString(@"
13-
digraph test {
14-
A;
15-
B;
16-
B -> B;
17-
A -> B[name = edgename];
18-
A -> B[name = edgename];
19-
A -> B[name = edgename];
20-
}
21-
");
22-
var A = root.GetNode("A");
23-
Assert.AreEqual(3, A.EdgesOut().Count());
24-
25-
var B = root.GetNode("B");
26-
_ = root.GetOrAddEdge(A, B, "");
27-
Assert.AreEqual(4, A.EdgesOut().Count());
28-
29-
root.ToSvgFile(TestContext.CurrentContext.TestDirectory + "/dot_out.svg");
30-
31-
root.ToSvgFile(TestContext.CurrentContext.TestDirectory + "/neato_out.svg", LayoutEngines.Neato);
12+
var test = new TestNugetPackage();
13+
test.TestReadDotFile();
3214
}
3315
}
3416
}
17+

Rubjerg.Graphviz/Rubjerg.Graphviz.csproj

Lines changed: 81 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@
1616
<Nullable>enable</Nullable>
1717
<NoWarn>1701;1702;NU5100</NoWarn>
1818
<DebugType>embedded</DebugType>
19-
20-
<!-- NuGet info -->
21-
<Version>2.0.2-dev.$([System.DateTime]::UtcNow.ToString("yyyyMMddHHmmss"))</Version>
22-
<Authors>Chiel ten Brinke</Authors>
23-
<Company>Rubjerg</Company>
24-
<Description>Lean wrapper around Graphviz for building graphs, reading/writing dot files, exporting images, or reading out layout parameters.</Description>
25-
<Copyright>Copyright 2020</Copyright>
26-
<PackageTags>graphviz dotnet graphdrawing</PackageTags>
27-
<RepositoryUrl>https://github.com/Rubjerg/Graphviz.NetWrapper</RepositoryUrl>
28-
<PackageProjectUrl>https://github.com/Rubjerg/Graphviz.NetWrapper</PackageProjectUrl>
29-
<PackageLicenseFile>LICENSE</PackageLicenseFile>
3019

3120
<Rid Condition=" '$(OS)' == 'Windows_NT' ">win-x64</Rid>
3221
<Rid Condition=" '$(OS)' != 'Windows_NT' ">linux-x64</Rid>
@@ -63,4 +52,85 @@
6352
</None>
6453
</ItemGroup>
6554

55+
56+
<!-- NuGet info -->
57+
<PropertyGroup>
58+
<Authors>Chiel ten Brinke</Authors>
59+
<Company>Rubjerg</Company>
60+
<Description>Lean wrapper around Graphviz for building graphs, reading/writing dot files, exporting images, or reading out layout parameters.</Description>
61+
<Copyright>Copyright 2020</Copyright>
62+
<PackageTags>graphviz dotnet graphdrawing</PackageTags>
63+
<RepositoryUrl>https://github.com/Rubjerg/Graphviz.NetWrapper</RepositoryUrl>
64+
<PackageProjectUrl>https://github.com/Rubjerg/Graphviz.NetWrapper</PackageProjectUrl>
65+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
66+
</PropertyGroup>
67+
68+
<!--
69+
The package version logic:
70+
- If the worktree is clean and on a version tag: 2.0.2
71+
- If the worktree is clean and ancestor of the master branch: 2.0.2-alpha-<commit>
72+
- Otherwise: 2.0.2-dev-<timestamp>
73+
-->
74+
75+
<Target Name="ComputeVersion" BeforeTargets="GenerateNuspec">
76+
<PropertyGroup>
77+
<_GitTmpFile>$(IntermediateOutputPath)git-info.txt</_GitTmpFile>
78+
<Timestamp>$([System.DateTime]::UtcNow.ToString("yyyyMMddHHmmss"))</Timestamp>
79+
</PropertyGroup>
80+
81+
<!-- 1. Get latest reachable tag -->
82+
<Exec Command="git describe --tags --abbrev=0 > &quot;$(_GitTmpFile)&quot;" />
83+
<ReadLinesFromFile File="$(_GitTmpFile)">
84+
<Output TaskParameter="Lines" PropertyName="LatestTag"/>
85+
</ReadLinesFromFile>
86+
87+
<!-- 2. Get exact tag at HEAD (may be blank) -->
88+
<Exec Command="(git describe --exact-match --tags HEAD || echo) > &quot;$(_GitTmpFile)&quot;" />
89+
<ReadLinesFromFile File="$(_GitTmpFile)">
90+
<Output TaskParameter="Lines" PropertyName="ExactTag"/>
91+
</ReadLinesFromFile>
92+
93+
<!-- 3. Get short commit hash -->
94+
<Exec Command="git rev-parse --short HEAD > &quot;$(_GitTmpFile)&quot;" />
95+
<ReadLinesFromFile File="$(_GitTmpFile)">
96+
<Output TaskParameter="Lines" PropertyName="CommitHash"/>
97+
</ReadLinesFromFile>
98+
99+
<!-- 4. Is working tree dirty? -->
100+
<Exec Command="git diff --quiet HEAD || echo dirty > &quot;$(_GitTmpFile)&quot;" />
101+
<ReadLinesFromFile File="$(_GitTmpFile)">
102+
<Output TaskParameter="Lines" PropertyName="DirtyOutput"/>
103+
</ReadLinesFromFile>
104+
105+
<!-- 5. Is master a descendant of HEAD? -->
106+
<Exec Command="git merge-base --is-ancestor HEAD master &amp;&amp; echo yes || echo no > &quot;$(_GitTmpFile)&quot;" />
107+
<ReadLinesFromFile File="$(_GitTmpFile)">
108+
<Output TaskParameter="Lines" PropertyName="MasterDescendant"/>
109+
</ReadLinesFromFile>
110+
111+
<!-- 6. Version logic -->
112+
<PropertyGroup>
113+
<BaseVersion>$([System.Text.RegularExpressions.Regex]::Replace($(LatestTag), '^v', ''))</BaseVersion>
114+
115+
<!-- Case 1: On exact tag, clean -->
116+
<_ResolvedVersion Condition="'$(ExactTag)' != '' and '$(DirtyOutput)' == ''">
117+
$(BaseVersion)
118+
</_ResolvedVersion>
119+
120+
<!-- Case 2: master is descendant of HEAD and clean -->
121+
<_ResolvedVersion Condition="'$(_ResolvedVersion)' == '' and '$(DirtyOutput)' == '' and '$(MasterDescendant)' == 'yes'">
122+
$(BaseVersion)-alpha-$(CommitHash)
123+
</_ResolvedVersion>
124+
125+
<!-- Case 3: anything else -->
126+
<_ResolvedVersion Condition="'$(_ResolvedVersion)' == ''">
127+
$(BaseVersion)-dev-$(Timestamp)
128+
</_ResolvedVersion>
129+
130+
<Version>$(_ResolvedVersion)</Version>
131+
</PropertyGroup>
132+
133+
<Message Text="Computed NuGet version: $(Version)" Importance="High"/>
134+
</Target>
135+
66136
</Project>

codecov.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)