Skip to content

Commit

Permalink
update prerelease mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Apr 5, 2024
1 parent 3a5c89a commit 66beafa
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 17 deletions.
13 changes: 9 additions & 4 deletions build/BasicTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ open BlackFox.Fake
open Fake.IO
open Fake.DotNet
open Fake.IO.Globbing.Operators
open Helpers

open ProjectInfo

Expand Down Expand Up @@ -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
}

Expand Down
35 changes: 34 additions & 1 deletion build/Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,37 @@ let runOrDefault defaultTarget args =
0
with e ->
printfn "%A" e
1
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

19 changes: 11 additions & 8 deletions build/PackageTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
open MessagePrompts
open BasicTasks
open TestTasks
open ProjectInfo
open Helpers

open BlackFox.Fake
open Fake.Core
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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]
let packPrerelease = BuildTask.createEmpty "PackPrerelease" [packDotNetPrerelease;packJSPrerelease;packPyPrerelease]
5 changes: 3 additions & 2 deletions build/ProjectInfo.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module ProjectInfo

open Fake.Core
open Helpers

let project = "ARCtrl"

Expand Down Expand Up @@ -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
20 changes: 19 additions & 1 deletion build/ReleaseTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ open ProjectInfo
open BasicTasks
open TestTasks
open PackageTasks
open Helpers

open BlackFox.Fake
open Fake.Core
Expand All @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
}
5 changes: 4 additions & 1 deletion src/Core/ARCtrl.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@
<ProjectReference Include="..\CWL\ARCtrl.CWL.fsproj" />
<ProjectReference Include="..\FileSystem\ARCtrl.FileSystem.fsproj" />
</ItemGroup>
<ItemGroup>
<None Include="../../build/logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
<PropertyGroup>
<Authors>nfdi4plants, Lukas Weil, Kevin Frey, Kevin Schneider, Oliver Muas</Authors>
<Authors>nfdi4plants, Lukas Weil, Kevin Frey, Kevin Schneider, Oliver Maus</Authors>
<Description>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.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>logo.png</PackageIcon>
Expand Down
3 changes: 3 additions & 0 deletions src/Json/ARCtrl.Json.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
<ItemGroup>
<ProjectReference Include="..\Core\ARCtrl.Core.fsproj" />
</ItemGroup>
<ItemGroup>
<None Include="../../build/logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
<PropertyGroup>
<Authors>nfdi4plants, Lukas Weil, Florian Wetzels, Kevin Frey</Authors>
<Description>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.</Description>
Expand Down
3 changes: 3 additions & 0 deletions src/Spreadsheet/ARCtrl.Spreadsheet.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<ItemGroup>
<PackageReference Include="FsSpreadsheet" Version="5.1.3" />
</ItemGroup>
<ItemGroup>
<None Include="../../build/logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<Content Include="*.fsproj; **\*.fs; **\*.fsi" PackagePath="fable\" />
</ItemGroup>
Expand Down

0 comments on commit 66beafa

Please sign in to comment.