TheAngryByrd / MiniScaffold

F# Template for creating and publishing libraries targeting .NET 6.0 `net6.0` or console apps .NET 6.0 `net6.0`.
https://www.jimmybyrd.me/MiniScaffold/
MIT License
267 stars 31 forks source link

Publish via CI #262

Closed TheAngryByrd closed 1 year ago

TheAngryByrd commented 1 year ago

Is your feature request related to a problem? Please describe.

I've moved a few projects like Marten.FSharp and IcedTasks to publish from github actions. I'm starting to prefer it and might be good to set as default.

Describe the solution you'd like

  1. Create a publish.yml similar to the ones above
  2. Need to update fake in the following ways: a. Change the set of targets to have a "Release" and a "Publish" target. Release will handle the Changelog and Git tag, Publish will handle the packaging, publish to nuget, and github release.

    
    "UpdateChangelog"
    ==> "GitRelease"
    ==>! "Release"
    
    "DotnetRestore"
    ==> "CheckFormatCode"
    ==> "DotnetBuild"
    // ==> "FSharpAnalyzers"
    ==> "DotnetTest"
    // =?> ("GenerateCoverageReport", not disableCodeCoverage)
    ==> "DotnetPack"
    ==> "PublishToNuGet"
    ==> "GitHubRelease"
    ==>! "Publish"

    b. fix the changelog diff link, aslinkReferenceForLatestEntry won't be generated once,, need to be mutable anymore and can just be remade on demand in mkReleaseNotes

      let mkReleaseNotes (latestEntry : Changelog.ChangelogEntry) =
        let linkReference = mkLinkReference latestEntry.SemVer changelog
        if String.isNullOrEmpty linkReference then latestEntry.ToString()
        else
            // Add link reference target to description before building release notes, since in main changelog file it's at the bottom of the file
            let description =
                match latestEntry.Description with
                | None -> linkReference
                | Some desc when desc.Contains(linkReference) -> desc
                | Some desc -> sprintf "%s\n\n%s" (desc.Trim()) linkReference
            { latestEntry with Description = Some description }.ToString()

    c. Fix prerelease changes

let prereleaseChanges = prereleaseEntries |> List.collect (fun entry -> entry.Changes |> List.filter (not << Changelog.isEmptyChange)) |> List.distinct

d. Create an allPublishChecks and update GithubRelease and PublishToNuget to use it


let allPublishChecks () =
    isOnCI ()
    Changelog.isChangelogEmpty ()

e. Figure out where docs fits in this this.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

gsvgit commented 1 year ago

Looks like you missed isRelease function modification (at least in this instructions, not sure about your repos). I guess, isRelease should looks like following to publish packages builded in Release mode.

let isRelease (targets : Target list) =
    targets
    |> Seq.map(fun t -> t.Name)
    |> Seq.exists (fun name -> name = "Release" || name = "Publish")