Skip to content

Commit

Permalink
ci: implemented incrementing patch version on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
xperiandri committed Nov 22, 2024
1 parent f21c1f7 commit 33817fc
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions build/build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ let failOnBadExitAndPrint (p : ProcessResult) =

failwithf "failed with exitcode %d" p.ExitCode

let isPublishToGitHub ctx = ctx.Context.FinalTarget = "PublishToGitHub"

let isCI = lazy environVarAsBoolOrDefault "CI" false

Expand Down Expand Up @@ -266,7 +267,25 @@ let dotnetRestore _ =
|> Seq.iter (retryIfInCI 10)

let updateChangelog ctx =
latestEntry <- Changelog.updateChangelog changelogPath changelog gitHubRepoUrl ctx
latestEntry <-
if not <| isPublishToGitHub ctx then
Changelog.updateChangelog changelogPath changelog gitHubRepoUrl ctx
else
let latest = changelog.LatestEntry
let semVer = {
latest.SemVer with
Patch = latest.SemVer.Patch + 1u
// Setting PreRelease has no effect on stringified version
//PreRelease = PreRelease.TryParse "ci"
PreRelease = None
}
{
latest with
SemVer = semVer
NuGetVersion = semVer.AsString
AssemblyVersion = semVer.AsString
}
printf ""

let revertChangelog _ =
if String.isNotNullOrEmpty Changelog.changelogBackupFilename then
Expand All @@ -286,7 +305,7 @@ let getPackageVersionProperty publishToGitHub =

let dotnetBuild ctx =

let publishToGitHub = ctx.Context.FinalTarget = "PublishToGitHub"
let publishToGitHub = isPublishToGitHub ctx

let args = [ getPackageVersionProperty publishToGitHub; "--no-restore" ]

Expand Down Expand Up @@ -447,10 +466,7 @@ let dotnetPack ctx =
// Get release notes with properly-linked version number
let releaseNotes = Changelog.mkReleaseNotes changelog latestEntry gitHubRepoUrl

let args = [
getPackageVersionProperty (ctx.Context.FinalTarget = "PublishToGitHub")
$"/p:PackageReleaseNotes=\"{releaseNotes}\""
]
let args = [ getPackageVersionProperty (isPublishToGitHub ctx); $"/p:PackageReleaseNotes=\"{releaseNotes}\"" ]

DotNet.pack
(fun c -> {
Expand Down Expand Up @@ -659,7 +675,7 @@ let initTargets (ctx : Context.FakeExecutionContext) =
==>! "ShowCoverageReport"

"UpdateChangelog"
=?> ("GenerateAssemblyInfo", not isPublishToGitHub)
==> "GenerateAssemblyInfo"
==> "GitRelease"
==>! "Release"

Expand Down

0 comments on commit 33817fc

Please sign in to comment.