Skip to content

Commit

Permalink
chore: add --allow-dirty and --allow-branch options for release
Browse files Browse the repository at this point in the history
  • Loading branch information
MangelMaxime committed Sep 8, 2024
1 parent 37f2dcc commit b4c9012
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions build/Commands/Release.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ If not specified, all projects will be released.
""")>]
member val Project = Project.All with get, set

[<CommandOption("--allow-dirty")>]
[<Description("Allow to run in a dirty repository (having not commit changes in your reporitory)")>]
member val AllowDirty: bool = false with get, set

[<CommandOption("--allow-branch <VALUES>")>]
[<Description("List of branches that are allowed to be used to generate the changelog. Default is 'main'")>]
member val AllowBranch: string array =
[|
"main"
|] with get, set

[<NoComparison>]
type ReleaseContext =
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b4c9012

Please sign in to comment.