Skip to content

Commit

Permalink
feat!: make the CLI return the version in stdout allowing other tools…
Browse files Browse the repository at this point in the history
… to capture the generate version easily
  • Loading branch information
MangelMaxime committed Nov 17, 2024
1 parent 3473311 commit 0c69cda
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Commands/Generate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,27 @@ type GenerateCommand() =
// do! Verify.options settings changelogInfo

let commits = ReleaseContext.getCommits settings changelogInfo
let releaseContext = ReleaseContext.compute settings changelogInfo commits config.CommitParserConfig

let releaseContext =
ReleaseContext.compute settings changelogInfo commits config.CommitParserConfig

match releaseContext with
| NoVersionBumpRequired -> Log.success "No version bump required."
| BumpRequired bumpInfo ->
let newChangelogContent = Changelog.updateWithNewVersion config.ChangelogGenConfig bumpInfo changelogInfo
let newChangelogContent =
Changelog.updateWithNewVersion
config.ChangelogGenConfig
bumpInfo
changelogInfo

if settings.DryRun then
Log.info "Dry run enabled, not writing to file."
printfn "%s" newChangelogContent
else
File.WriteAllText(changelogInfo.File.FullName, newChangelogContent)
Log.success ($"Changelog updated with new version {bumpInfo.NewVersion}.")
Log.success ($"Changelog updated with new version:")
// Print to stdout so it can be captured easily by other tools
printfn "%s" (bumpInfo.NewVersion.ToString())
}

match res with
Expand Down

0 comments on commit 0c69cda

Please sign in to comment.