From b4c90120754bc99cd66712e9e240013751f9eff5 Mon Sep 17 00:00:00 2001 From: Maxime Mangel Date: Sun, 8 Sep 2024 20:54:36 +0200 Subject: [PATCH] chore: add `--allow-dirty` and `--allow-branch` options for release --- build/Commands/Release.fs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/build/Commands/Release.fs b/build/Commands/Release.fs index 31bec52..9ccbf93 100644 --- a/build/Commands/Release.fs +++ b/build/Commands/Release.fs @@ -73,6 +73,17 @@ If not specified, all projects will be released. """)>] member val Project = Project.All with get, set + [] + [] + member val AllowDirty: bool = false with get, set + + [")>] + [] + member val AllowBranch: string array = + [| + "main" + |] with get, set + [] type ReleaseContext = { @@ -428,10 +439,10 @@ type ReleaseCommand() = // It also doesn't support SSH use repository = new Repository(Workspace.``.``) - if repository.Head.FriendlyName <> "main" then - failwith "You must be on the main branch to publish" + if not (Array.contains repository.Head.FriendlyName settings.AllowBranch) then + failwith $"Branch '{repository.Head.FriendlyName}' is not allowed to make a release" - if repository.RetrieveStatus().IsDirty then + if repository.RetrieveStatus().IsDirty && not settings.AllowDirty then failwith "You must commit your changes before publishing" match settings.Project with