From 66beafac306e18d56ef2c5edc969e7eb10b4ea2f Mon Sep 17 00:00:00 2001 From: HLWeil Date: Fri, 5 Apr 2024 12:57:30 +0200 Subject: [PATCH] update prerelease mechanism --- build/BasicTasks.fs | 13 ++++++--- build/Helpers.fs | 35 ++++++++++++++++++++++- build/PackageTasks.fs | 19 ++++++------ build/ProjectInfo.fs | 5 ++-- build/ReleaseTasks.fs | 20 ++++++++++++- src/Core/ARCtrl.Core.fsproj | 5 +++- src/Json/ARCtrl.Json.fsproj | 3 ++ src/Spreadsheet/ARCtrl.Spreadsheet.fsproj | 3 ++ 8 files changed, 86 insertions(+), 17 deletions(-) diff --git a/build/BasicTasks.fs b/build/BasicTasks.fs index 449e4f9f..67c42bf5 100644 --- a/build/BasicTasks.fs +++ b/build/BasicTasks.fs @@ -4,6 +4,7 @@ open BlackFox.Fake open Fake.IO open Fake.DotNet open Fake.IO.Globbing.Operators +open Helpers open ProjectInfo @@ -134,11 +135,15 @@ module Helper = |> Proc.Parallel.run |> ignore + + let setPrereleaseTag = BuildTask.create "SetPrereleaseTag" [] { - printfn "Please enter pre-release package suffix" - let suffix = System.Console.ReadLine() - prereleaseSuffix <- suffix - prereleaseTag <- (sprintf "%i.%i.%i-%s" release.SemVer.Major release.SemVer.Minor release.SemVer.Patch suffix) + printfn "Please enter pre-release package suffix option: (a/b/rc)" + let suffixTag = System.Console.ReadLine() |> PreReleaseFlag.fromInput + printfn "Plrease enter pre-release package version number" + let suffixNumber = System.Console.ReadLine() |> int + prereleaseSuffix <- suffixTag + prereleaseSuffixNumber <- suffixNumber isPrerelease <- true } diff --git a/build/Helpers.fs b/build/Helpers.fs index 5dd1ed80..cb00dddb 100644 --- a/build/Helpers.fs +++ b/build/Helpers.fs @@ -25,4 +25,37 @@ let runOrDefault defaultTarget args = 0 with e -> printfn "%A" e - 1 \ No newline at end of file + 1 + +type PreReleaseFlag = + | Alpha + | Beta + | ReleaseCandidate + + static member fromInput (input: string) = + match input with + | "a" -> Alpha + | "b" -> Beta + | "rc" -> ReleaseCandidate + | _ -> failwith "Invalid input" + + static member toNugetTag (semVer : SemVerInfo) (flag: PreReleaseFlag) (number : int) = + let suffix = + match flag with + | Alpha -> $"alpha.{number}" + | Beta -> $"beta.{number}" + | ReleaseCandidate -> $"rc.{number}" + sprintf "%i.%i.%i-%s" semVer.Major semVer.Minor semVer.Patch suffix + + + static member toNPMTag (semVer : SemVerInfo) (flag: PreReleaseFlag) (number : int) = + PreReleaseFlag.toNugetTag semVer flag number + + static member toPyPITag (semVer : SemVerInfo) (tag: PreReleaseFlag) (number : int) = + let suffix = + match tag with + | Alpha -> $"a{number}" + | Beta -> $"b{number}" + | ReleaseCandidate -> $"rc{number}" + sprintf "%i.%i.%i%s" semVer.Major semVer.Minor semVer.Patch suffix + diff --git a/build/PackageTasks.fs b/build/PackageTasks.fs index 6d073b24..42f6debd 100644 --- a/build/PackageTasks.fs +++ b/build/PackageTasks.fs @@ -3,6 +3,8 @@ open MessagePrompts open BasicTasks open TestTasks +open ProjectInfo +open Helpers open BlackFox.Fake open Fake.Core @@ -41,7 +43,8 @@ let packDotNet = BuildTask.create "PackDotNet" [clean; build; runTests] { } let packDotNetPrerelease = BuildTask.create "PackDotNetPrerelease" [setPrereleaseTag; clean; build; runTests] { - BundleDotNet.bundle ProjectInfo.prereleaseTag (Some ProjectInfo.prereleaseTag) + let prereleaseTag = PreReleaseFlag.toNugetTag release.SemVer prereleaseSuffix prereleaseSuffixNumber + BundleDotNet.bundle prereleaseTag (Some prereleaseTag) } module BundleJs = @@ -69,7 +72,8 @@ let packJS = BuildTask.create "PackJS" [clean; build; runTests] { } let packJSPrerelease = BuildTask.create "PackJSPrerelease" [setPrereleaseTag; clean; build; runTests] { - BundleJs.bundle ProjectInfo.prereleaseTag + let prereleaseTag = PreReleaseFlag.toNPMTag release.SemVer prereleaseSuffix prereleaseSuffixNumber + BundleJs.bundle prereleaseTag } module BundlePy = @@ -98,13 +102,12 @@ let packPy = BuildTask.create "PackPy" [clean; build; runTests] { } -//let packPyPrerelease = BuildTask.create "PackJSPrerelease" [setPrereleaseTag; clean; build; runTests] { -// if promptYesNo (sprintf "[NPM] package tag will be %s OK?" ProjectInfo.prereleaseTag ) then -// BundleJs.bundle ProjectInfo.prereleaseTag -// else failwith "aborted" -// } +let packPyPrerelease = BuildTask.create "PackPyPrerelease" [setPrereleaseTag; clean; build; runTests] { + let prereleaseTag = PreReleaseFlag.toPyPITag release.SemVer prereleaseSuffix prereleaseSuffixNumber + BundlePy.bundle prereleaseTag + } let pack = BuildTask.createEmpty "Pack" [packDotNet; packJS; packPy] -let packPrerelease = BuildTask.createEmpty "PackPrerelease" [packDotNetPrerelease;packJSPrerelease] \ No newline at end of file +let packPrerelease = BuildTask.createEmpty "PackPrerelease" [packDotNetPrerelease;packJSPrerelease;packPyPrerelease] \ No newline at end of file diff --git a/build/ProjectInfo.fs b/build/ProjectInfo.fs index f8f79b97..128cf543 100644 --- a/build/ProjectInfo.fs +++ b/build/ProjectInfo.fs @@ -1,6 +1,7 @@ module ProjectInfo open Fake.Core +open Helpers let project = "ARCtrl" @@ -50,8 +51,8 @@ let stableVersion = SemVer.parse release.NugetVersion let stableVersionTag = (sprintf "%i.%i.%i" stableVersion.Major stableVersion.Minor stableVersion.Patch ) -let mutable prereleaseSuffix = "" +let mutable prereleaseSuffix = PreReleaseFlag.Alpha -let mutable prereleaseTag = "" +let mutable prereleaseSuffixNumber = 0 let mutable isPrerelease = false \ No newline at end of file diff --git a/build/ReleaseTasks.fs b/build/ReleaseTasks.fs index 9086d5cd..7be87479 100644 --- a/build/ReleaseTasks.fs +++ b/build/ReleaseTasks.fs @@ -5,6 +5,7 @@ open ProjectInfo open BasicTasks open TestTasks open PackageTasks +open Helpers open BlackFox.Fake open Fake.Core @@ -23,6 +24,8 @@ let createTag = BuildTask.create "CreateTag" [clean; build; runTests; packDotNet } let createPrereleaseTag = BuildTask.create "CreatePrereleaseTag" [setPrereleaseTag; clean; build; runTests; packDotNetPrerelease] { + let prereleaseTag = PreReleaseFlag.toNugetTag release.SemVer prereleaseSuffix prereleaseSuffixNumber + if promptYesNo (sprintf "tagging branch with %s OK?" prereleaseTag ) then Git.Branches.tag "" prereleaseTag Git.Branches.pushTag "" projectRepo prereleaseTag @@ -46,6 +49,7 @@ let publishNuget = BuildTask.create "PublishNuget" [clean; build; runTests; pack let publishNugetPrerelease = BuildTask.create "PublishNugetPrerelease" [clean; build; runTests; packDotNetPrerelease] { let targets = (!! (sprintf "%s/*.*pkg" netPkgDir )) for target in targets do printfn "%A" target + let prereleaseTag = PreReleaseFlag.toNugetTag release.SemVer prereleaseSuffix prereleaseSuffixNumber let msg = sprintf "[NUGET] release package with version %s?" prereleaseTag if promptYesNo msg then let source = "https://api.nuget.org/v3/index.json" @@ -77,6 +81,7 @@ let publishNPMPrerelease = BuildTask.create "PublishNPMPrerelease" [clean; build (!! (sprintf "%s/*.tgz" npmPkgDir )) |> Seq.head printfn "%A" target + let prereleaseTag = PreReleaseFlag.toNPMTag release.SemVer prereleaseSuffix prereleaseSuffixNumber let msg = sprintf "[NPM] release package with version %s?" prereleaseTag if promptYesNo msg then let apikey = Environment.environVarOrNone "NPM_KEY" @@ -88,7 +93,7 @@ let publishNPMPrerelease = BuildTask.create "PublishNPMPrerelease" [clean; build else failwith "aborted" } -let publishPyPi = BuildTask.create "PublishPyPi" [packPy] { +let publishPyPi = BuildTask.create "PublishPyPi" [clean; build; runTests; packPy] { let msg = sprintf "[PyPi] release package with version %s?" stableVersionTag if promptYesNo msg then let apikey = Environment.environVarOrNone "PYPI_KEY" @@ -98,4 +103,17 @@ let publishPyPi = BuildTask.create "PublishPyPi" [packPy] { | None -> () run python "-m poetry publish" ProjectInfo.pyPkgDir else failwith "aborted" +} + +let publishPyPiPrerelease = BuildTask.create "PublishPyPiPrerelease" [clean; build; runTests; packPyPrerelease] { + let prereleaseTag = PreReleaseFlag.toPyPITag release.SemVer prereleaseSuffix prereleaseSuffixNumber + let msg = sprintf "[PyPi] release package with version %s?" prereleaseTag + if promptYesNo msg then + let apikey = Environment.environVarOrNone "PYPI_KEY" + match apikey with + | Some key -> + run python $"-m poetry config pypi-token.pypi {key}" ProjectInfo.pyPkgDir + | None -> () + run python "-m poetry publish --build" ProjectInfo.pyPkgDir + else failwith "aborted" } \ No newline at end of file diff --git a/src/Core/ARCtrl.Core.fsproj b/src/Core/ARCtrl.Core.fsproj index 8e0f6836..d94424ca 100644 --- a/src/Core/ARCtrl.Core.fsproj +++ b/src/Core/ARCtrl.Core.fsproj @@ -56,8 +56,11 @@ + + + - nfdi4plants, Lukas Weil, Kevin Frey, Kevin Schneider, Oliver Muas + nfdi4plants, Lukas Weil, Kevin Frey, Kevin Schneider, Oliver Maus ARC and ISA compliant experimental metadata toolkit in F#. This project is meant as an easy means to open, manipulate and save ISA (Investigation,Study,Assay) metadata files in the dotnet environment. MIT logo.png diff --git a/src/Json/ARCtrl.Json.fsproj b/src/Json/ARCtrl.Json.fsproj index 50497f3d..66883016 100644 --- a/src/Json/ARCtrl.Json.fsproj +++ b/src/Json/ARCtrl.Json.fsproj @@ -83,6 +83,9 @@ + + + nfdi4plants, Lukas Weil, Florian Wetzels, Kevin Frey ARC and ISA json compliant parser for experimental metadata toolkit in F#. This project is meant as an easy means to open, manipulate and save ISA (Investigation,Study,Assay) metadata files in isa-json format. diff --git a/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj b/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj index d5a6f817..1df8bcca 100644 --- a/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj +++ b/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj @@ -31,6 +31,9 @@ + + +