From 953ee69b3ae4d7cc74a725e1a2872c1e252ee32c Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Wed, 13 Dec 2023 13:33:39 +0800 Subject: [PATCH] Tools,Fsdk: move prerelease version gen to Fsdk End goal: https://github.com/fsprojects/FSharpLint/pull/544 --- Fsdk/Network.fs | 26 ++++++++++++++++++++++++++ Tools/nugetPush.fsx | 30 ++---------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Fsdk/Network.fs b/Fsdk/Network.fs index fe1a2098..5ffea80a 100644 --- a/Fsdk/Network.fs +++ b/Fsdk/Network.fs @@ -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() + + if isNull 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 NugetDownloadUrl = "https://dist.nuget.org/win-x86-commandline/v5.4.0/nuget.exe" diff --git a/Tools/nugetPush.fsx b/Tools/nugetPush.fsx index fdd8462f..28268736 100755 --- a/Tools/nugetPush.fsx +++ b/Tools/nugetPush.fsx @@ -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 @@ -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 = @@ -115,7 +89,7 @@ let FindOrGenerateNugetPackages() : seq = 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