Skip to content

Commit

Permalink
Tools,Fsdk: move prerelease version gen to Fsdk
Browse files Browse the repository at this point in the history
  • Loading branch information
knocte committed Dec 13, 2023
1 parent 2737eea commit 22d842f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Fsdk/Fsdk-legacy.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
<Compile Include="Misc.fs" />
<Compile Include="Process.fs" />
<Compile Include="Unix.fs" />
<Compile Include="Network.fs" />
<Compile Include="Git.fs" />
<Compile Include="Network.fs" />
<Compile Include="Taiga.fs" />
</ItemGroup>
<Import Project="..\CommonBuildProps-legacy.proj" />
Expand Down
26 changes: 26 additions & 0 deletions Fsdk/Network.fs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,32 @@ module Network =
GetPrivateIpOfThisServer()
)

// this is a translation of doing this in unix (assuming initialVersion="0.1.0"):
// 0.1.0--date`date +%Y%m%d-%H%M`.git-`git rev-parse --short=7 HEAD`
let GetNugetPrereleaseVersionFromBaseVersion(baseVersion: string) =
let initialVersion =
let versionSplit = baseVersion.Split '.'

if versionSplit.Length = 4 && versionSplit.[3] = "0" then
String.Join(".", versionSplit.Take 3)
else
baseVersion

let dateSegment =
sprintf "date%s" (DateTime.UtcNow.ToString "yyyyMMdd-hhmm")

let gitHash = Git.GetLastCommit()

Check failure on line 438 in Fsdk/Network.fs

View workflow job for this annotation

GitHub Actions / macOS--dotnet6-and-mono

The value, namespace, type or module 'Git' is not defined. Maybe you want one of the following:� Guid

Check failure on line 438 in Fsdk/Network.fs

View workflow job for this annotation

GitHub Actions / macOS--dotnet6-and-mono

The value, namespace, type or module 'Git' is not defined. Maybe you want one of the following:� Guid

Check failure on line 438 in Fsdk/Network.fs

View workflow job for this annotation

GitHub Actions / macOS--dotnet6-and-mono

The value, namespace, type or module 'Git' is not defined. Maybe you want one of the following:� Guid

Check failure on line 438 in Fsdk/Network.fs

View workflow job for this annotation

GitHub Actions / macOS--dotnet6-and-mono

The value, namespace, type or module 'Git' is not defined. Maybe you want one of the following:� Guid

if isNull gitHash then
Console.Error.WriteLine "Not in a git repository?"
Environment.Exit 2

let gitHashDefaultShortLength = 7
let gitShortHash = gitHash.Substring(0, gitHashDefaultShortLength)

Check failure on line 445 in Fsdk/Network.fs

View workflow job for this annotation

GitHub Actions / macOS--dotnet6-and-mono

Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.

Check failure on line 445 in Fsdk/Network.fs

View workflow job for this annotation

GitHub Actions / macOS--dotnet6-and-mono

Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.

Check failure on line 445 in Fsdk/Network.fs

View workflow job for this annotation

GitHub Actions / macOS--dotnet6-and-mono

Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.

Check failure on line 445 in Fsdk/Network.fs

View workflow job for this annotation

GitHub Actions / macOS--dotnet6-and-mono

Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
let gitSegment = sprintf "git-%s" gitShortHash
let finalVersion = sprintf "%s--%s.%s" initialVersion dateSegment gitSegment
finalVersion

let NugetDownloadUrl =
"https://dist.nuget.org/win-x86-commandline/v5.4.0/nuget.exe"

Expand Down
30 changes: 2 additions & 28 deletions Tools/nugetPush.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ open System.Configuration

#load "../Fsdk/Misc.fs"
#load "../Fsdk/Process.fs"
#load "../Fsdk/Network.fs"
#load "../Fsdk/Git.fs"
#load "../Fsdk/Network.fs"

open Fsdk
open Fsdk.Process
Expand All @@ -31,32 +31,6 @@ if args.Length > 2 && args.[0] <> "--output-version" then

let currentDir = Directory.GetCurrentDirectory() |> DirectoryInfo

// this is a translation of doing this in unix (assuming initialVersion="0.1.0"):
// 0.1.0--date`date +%Y%m%d-%H%M`.git-`git rev-parse --short=7 HEAD`
let GetIdealNugetVersion(inputVersion: string) =
let initialVersion =
let versionSplit = inputVersion.Split '.'

if versionSplit.Length = 4 && versionSplit.[3] = "0" then
String.Join(".", versionSplit.Take 3)
else
inputVersion

let dateSegment =
sprintf "date%s" (DateTime.UtcNow.ToString "yyyyMMdd-hhmm")

let gitHash = Git.GetLastCommit()

if null = gitHash then
Console.Error.WriteLine "Not in a git repository?"
Environment.Exit 2

let gitHashDefaultShortLength = 7
let gitShortHash = gitHash.Substring(0, gitHashDefaultShortLength)
let gitSegment = sprintf "git-%s" gitShortHash
let finalVersion = sprintf "%s--%s.%s" initialVersion dateSegment gitSegment
finalVersion

let IsDotNetSdkInstalled() =
try
let dotnetVersionCmd =
Expand Down Expand Up @@ -115,7 +89,7 @@ let FindOrGenerateNugetPackages() : seq<FileInfo> =
let packageName =
Path.GetFileNameWithoutExtension nuspecFile.FullName

let nugetVersion = GetIdealNugetVersion baseVersion
let nugetVersion = Network.GetPrereleaseNugetVersionFromBaseVersion baseVersion

// we need to download nuget.exe here because `dotnet pack` doesn't support using standalone (i.e.
// without a project association) .nuspec files, see https://github.com/NuGet/Home/issues/4254
Expand Down

0 comments on commit 22d842f

Please sign in to comment.