@@ -13,7 +13,7 @@ let rootDir = __SOURCE_DIRECTORY__ </> ".."
1313let solutionFile = " Flips.sln"
1414
1515// Github repo
16- let repo = " https://github.com/matthewcrews /flips"
16+ let repo = " https://github.com/fslaborg /flips"
1717
1818// Read additional information from the release notes document
1919let release = ReleaseNotes.load ( rootDir @@ " RELEASE_NOTES.md" )
@@ -186,43 +186,50 @@ let initTargets () =
186186 // --------------------------------------------------------------------------------------
187187 // Release Scripts
188188
189- let gitPush msg =
190- Git.Staging.stageAll " "
191- Git.Commit.exec " " msg
192- Git.Branches.push " "
193-
194- Target.create " GitPush"
189+ Target.create " Publish"
195190 <| fun p ->
196- p.Context.Arguments
197- |> List.choose ( fun s ->
198- match s.StartsWith( " --Msg=" ) with
199- | true -> Some( s.Substring 6 )
200- | false -> None)
201- |> List.tryHead
202- |> function
203- | Some( s) -> s
204- | None -> ( sprintf " Bump version to %s " release.NugetVersion)
205- |> gitPush
206-
207- Target.create " GitTag"
208- <| fun _ ->
209- Git.Branches.tag " " release.NugetVersion
210- Git.Branches.pushTag " " " origin" release.NugetVersion
191+ // Expect version to be released a argument as a sanity check to prevent releases by accident.
192+ let announcedVersion =
193+ match p.Context.Arguments |> List.tryHead with
194+ | None -> failwithf " Please specify a version number, e.g. '... -t Publish 2.5.0'"
195+ | Some version -> version
196+
197+ if announcedVersion <> release.NugetVersion then
198+ failwithf
199+ " Version '%s ' does not match latest version in the RELEASE_NOTES '%s '"
200+ announcedVersion
201+ release.NugetVersion
202+
203+ let currentBranch = Git.Information.getBranchName " "
204+
205+ if not ( Git.Information.isCleanWorkingCopy " " ) then
206+ failwith " You must have a clean working copy to release. Please commit or stash your changes."
207+
208+ if currentBranch <> " main" then
209+ failwithf " You must be on the 'main' branch to release. Current branch is '%s '" currentBranch
210+
211+ let local = Git.Information.getCurrentSHA1 " "
212+ let remote = Git.Branches.getSHA1 " " ( " origin/" + currentBranch)
213+
214+ if Git.Information.isAheadOf " " local remote then
215+ failwithf
216+ " Your local branch must not be ahead of the remote branch '%s '. Please push your changes before releasing."
217+ currentBranch
218+
219+ let tagName = sprintf " v%s " release.NugetVersion
220+ Git.Branches.tag " " tagName
211221
212222 // --------------------------------------------------------------------------------------
213223 // Run all targets by default. Invoke 'build -t <Target>' to override
214224
215225 Target.create " All" ignore
216226 Target.create " Dev" ignore
217227 Target.create " Release" ignore
218- Target.create " Publish" ignore
219228
220229 " Clean" ==> " Restore" ==> " Build" |> ignore
221230
222231 " Build" ==> " RunTests" |> ignore
223232
224- " All" ==> " GitPush" ?=> " GitTag" |> ignore
225-
226233 " All" <== [ " RunTests" ]
227234
228235 " CleanDocs" ==> " CopyDocFiles" ==> " PrepDocs" |> ignore
@@ -238,8 +245,7 @@ let initTargets () =
238245
239246 " Release" <== [ " All" ; " NuGet" ; " ConfigRelease" ]
240247
241- " Publish"
242- <== [ " Release" ; " ConfigRelease" ; " NuGetPublish" ; " Build" ; " GitTag" ; " GitPush" ]
248+ " Release" ==> " Publish" |> ignore
243249
244250[<EntryPoint>]
245251let main argv =
0 commit comments