SSH.NET icon indicating copy to clipboard operation
SSH.NET copied to clipboard

Integrate with Nerdbank.GitVersioning

Open scott-xu opened this issue 1 year ago • 10 comments

scott-xu avatar Jan 29 '24 14:01 scott-xu

Interesting. Would this change how one creates a release? If so, what would be the steps required?

Rob-Hague avatar Jan 30 '24 12:01 Rob-Hague

From reading the doc about nbgv, the first step is to run nbgv prepare-release. See help below

C:\Users\scott\source\repos\scott-xu\SSH.NET> nbgv prepare-release --help
Description:
  Prepares a release by creating a release branch for the current version and adjusting the version on the current branch.

Usage:
  nbgv prepare-release [<tag>] [options]

Arguments:
  <tag>  The prerelease tag to apply on the release branch (if any). If not specified, any existing prerelease tag will be removed. The preceding hyphen may be omitted.

Options:
  -p, --project <project>                The path to the project or project directory. The default is the current directory.
  --nextVersion <nextVersion>            The version to set for the current branch. If omitted, the next version is determined automatically by incrementing the current version.
  --versionIncrement <versionIncrement>  Overrides the 'versionIncrement' setting set in version.json for determining the next version of the current branch.
  -f, --format <json|text>               The format to write information about the release. Allowed values are: text, json. The default is text.
  -?, -h, --help                         Show help and usage information

Then grab a cup of coffee and wait the Appveyor to build the project, generate the nuget package, test the project, and finally deploy the nuget package to nuget.org. Obviously we need to config the Appveyor properly first.

scott-xu avatar Jan 30 '24 13:01 scott-xu

I get a weird error when building this branch

1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly.
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: Nerdbank.GitVersioning.GitException: Got a com instead of a tag when opening object 1c7166a002d7633fe1595b3df4634ba0ef6e3138
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.ManagedGit.GitRepository.TryGetObjectByPath(GitObjectId sha, String objectType, Stream& value)
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.ManagedGit.GitRepository.TryGetObjectBySha(GitObjectId sha, String objectType, Stream& value)
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.ManagedGit.GitRepository.<LookupTags>g__HandleCandidate|44_0(GitObjectId pointsAt, String tagName, Boolean isPeeled, <>c__DisplayClass44_0& )
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.ManagedGit.GitRepository.LookupTags(GitObjectId objectId)
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.Managed.ManagedGitContext.get_HeadTags()
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle..ctor(GitContext context, ICloudBuild cloudBuild, Nullable`1 overrideVersionHeightOffset)
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner() in D:\a\1\s\src\Nerdbank.GitVersioning.Tasks\GetBuildVersion.cs:line 240
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Users\rhague\.nuget\packages\nerdbank.gitversioning\3.7.48-alpha\build\Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Rob-Hague avatar Jan 31 '24 12:01 Rob-Hague

I get a weird error when building this branch

It seems to be a bug in the Nerdbank package, where it does not correctly handle lightweight tags in .git/ref/tags (e.g. 2023.0.1).

In a fresh clone, the tags are in .git/packed-refs which are handled correctly, hence it passing in CI. In my local copy of the repo, the tags are in .git/ref/tags and it is assuming they are all annotated tags.

Rob-Hague avatar Jan 31 '24 17:01 Rob-Hague

It updates the CI build number: image

scott-xu avatar Feb 16 '24 14:02 scott-xu

I've not forgotten about this PR, I just want to read up some more on the configuration

Rob-Hague avatar Feb 16 '24 18:02 Rob-Hague

Not very familar with current release process, but it seems to be some manual work?

scott-xu avatar Feb 25 '24 07:02 scott-xu

Yes it is manual

WojciechNagorski avatar Feb 25 '24 07:02 WojciechNagorski

I guess the current release process is based on https://github.com/sshnet/BuildTools and https://github.com/sshnet/SSH.NET/blob/develop/build/build.proj, am I right? @WojciechNagorski No matter merge this PR or not, I recommend delegating the release process to appveyor

scott-xu avatar Feb 25 '24 07:02 scott-xu

Currently it is just dotnet pack right now.

WojciechNagorski avatar Feb 25 '24 09:02 WojciechNagorski

I actually have some local changes for this, let me fix the merge and push them in

Rob-Hague avatar Jul 26 '24 17:07 Rob-Hague

Example on a PR branch:

internal static partial class ThisAssembly {
    internal const string AssemblyConfiguration = "Release";
    internal const string AssemblyFileVersion = "2024.1.1";
    internal const string AssemblyInformationalVersion = "2024.1.1-prerelease.2+84ff4f6671";
    internal const string AssemblyName = "Renci.SshNet";
    internal const string AssemblyTitle = "SSH.NET";
    internal const string AssemblyVersion = "2024.1.1.0";
    internal static readonly global::System.DateTime GitCommitDate = new global::System.DateTime(638576102900000000L, global::System.DateTimeKind.Utc);
    internal const string GitCommitId = "84ff4f66711638341a0d856299f7a62ae4bbf38b";
    internal const bool IsPrerelease = true;
    internal const bool IsPublicRelease = false;
    internal const string NuGetPackageVersion = "2024.1.1-prerelease.2.g84ff4f6671";
    internal const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100f9194e1eb66b7e2575aaee115ee1d27bc100920e7150e43992d6f668f9737de8b9c7ae892b62b8a36dd1d57929ff1541665d101dc476d6e02390846efae7e5186eec409710fdb596e3f83740afef0d4443055937649bc5a773175b61c57615dac0f0fd10f52b52fedf76c17474cc567b3f7a79de95dde842509fb39aaf69c6c2";
    internal const string PublicKeyToken = "1cee9f8bde3db106";
    internal const string RootNamespace = "Renci.SshNet";
}

image

Example on a simulated "public" branch e.g. develop:

internal static partial class ThisAssembly {
    internal const string AssemblyConfiguration = "Release";
    internal const string AssemblyFileVersion = "2024.1.1";
    internal const string AssemblyInformationalVersion = "2024.1.1-prerelease.3+57319f736f";
    internal const string AssemblyName = "Renci.SshNet";
    internal const string AssemblyTitle = "SSH.NET";
    internal const string AssemblyVersion = "2024.1.1.0";
    internal static readonly global::System.DateTime GitCommitDate = new global::System.DateTime(638576099590000000L, global::System.DateTimeKind.Utc);
    internal const string GitCommitId = "57319f736f1d0dbf25455f121669223d8fc48893";
    internal const bool IsPrerelease = true;
    internal const bool IsPublicRelease = true;
    internal const string NuGetPackageVersion = "2024.1.1-prerelease.3";
    internal const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100f9194e1eb66b7e2575aaee115ee1d27bc100920e7150e43992d6f668f9737de8b9c7ae892b62b8a36dd1d57929ff1541665d101dc476d6e02390846efae7e5186eec409710fdb596e3f83740afef0d4443055937649bc5a773175b61c57615dac0f0fd10f52b52fedf76c17474cc567b3f7a79de95dde842509fb39aaf69c6c2";
    internal const string PublicKeyToken = "1cee9f8bde3db106";
    internal const string RootNamespace = "Renci.SshNet";
}

image

Rob-Hague avatar Jul 26 '24 18:07 Rob-Hague

The appveyor nuget feed is in operation:

image

Rob-Hague avatar Jul 27 '24 11:07 Rob-Hague