Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Packaging Build targets and versioning #226

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refine executable publish commands
HLWeil committed Nov 9, 2023
commit 39413b56ecff257a22faf341193cfeaa0ea2032a
4 changes: 2 additions & 2 deletions build/Build.fs
Original file line number Diff line number Diff line change
@@ -18,13 +18,13 @@ DockerTasks.dockerPublish |> ignore
let _release =
BuildTask.createEmpty
"Release"
[clean; build; copyBinaries; runTests; pack; createTag; publishNuget]
[clean; build; copyBinaries; runTests; publishBinariesAll]

/// Full release of nuget package, git tag, and documentation for the prerelease version.
let _preRelease =
BuildTask.createEmpty
"PreRelease"
[setPrereleaseTag; clean; build; copyBinaries; runTests; packPrerelease; createPrereleaseTag; publishNugetPrerelease]
[setPrereleaseTag; clean; build; copyBinaries; runTests; publishBinariesAllPrerelease]

[<EntryPoint>]
let main args = runOrDefault args
179 changes: 64 additions & 115 deletions build/PackageTasks.fs
Original file line number Diff line number Diff line change
@@ -12,149 +12,98 @@ open Helpers
open BasicTasks
open TestTasks

let pack = BuildTask.create "Pack" [clean; build; runTests; copyBinaries] {
if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag )
then
!! "src/**/*.*proj"
|> Seq.iter (Fake.DotNet.DotNet.pack (fun p ->
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"Version",stableVersionTag
"PackageReleaseNotes", (release.Notes |> String.concat "\r\n")
] @ p.MSBuildParams.Properties)
}
{
p with
MSBuildParams = msBuildParams
OutputPath = Some pkgDir
NoBuild = true
Configuration = DotNet.BuildConfiguration.fromString configuration
}
))
else failwith "aborted"
}
type RunTime =
| Win
| Linux
| Mac
| MacARM

let packPrerelease = BuildTask.create "PackPrerelease" [setPrereleaseTag; clean; build; runTests; copyBinaries] {
if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag )
then
!! "src/**/*.*proj"
//-- "src/**/Plotly.NET.Interactive.fsproj"
|> Seq.iter (Fake.DotNet.DotNet.pack (fun p ->
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"Version", prereleaseTag
"PackageReleaseNotes", (release.Notes |> String.toLines )
] @ p.MSBuildParams.Properties)
}
{
p with
VersionSuffix = Some prereleaseSuffix
OutputPath = Some pkgDir
NoBuild = true
Configuration = DotNet.BuildConfiguration.fromString configuration
}
))
else
failwith "aborted"
}
member this.GetRuntime() =
match this with
| Win -> "win-x64"
| Linux -> "linux-x64"
| Mac -> "osx-x64"
| MacARM -> "osx-arm64"

let publishBinariesWin = BuildTask.create "PublishBinariesWin" [clean.IfNeeded; build.IfNeeded] {
let outputPath = sprintf "%s/win-x64" publishDir
"src/ArcCommander/ArcCommander.fsproj"
member this.GetRuntimeFolder() =
match this with
| Win -> "win-x64"
| Linux -> "linux-x64"
| Mac -> "osx-x64"
| MacARM -> "osx-arm64"

member this.GetPlatform() =
match this with
| Win -> "x64"
| Linux -> "x64"
| Mac -> "x64"
| MacARM -> "arm64"


let publishBinaries (version : string) (versionSuffix : string Option) (runtime : RunTime) =
printfn "Published version %s and runtime %O" version runtime
let outputFolder = runtime.GetRuntimeFolder()
let outputPath = sprintf "%s/%s" publishDir outputFolder
project
|> DotNet.publish (fun p ->
let standardParams = Fake.DotNet.MSBuild.CliArguments.Create ()
{
p with
Runtime = Some "win-x64"
Runtime = Some (runtime.GetRuntime())
Configuration = DotNet.BuildConfiguration.fromString configuration
OutputPath = Some outputPath
MSBuildParams = {
standardParams with
Properties = [
"Version", stableVersionTag
"Platform", "x64"
"VersionPrefix", version
if versionSuffix.IsSome then "VersionSuffix", versionSuffix.Value
"Platform", runtime.GetPlatform()
"PublishSingleFile", "true"
]
};
}
}

)
printfn "Beware that assemblyName differs from projectName!"



let publishBinariesWin = BuildTask.create "PublishBinariesWin" [clean.IfNeeded; build.IfNeeded] {
publishBinaries stableVersionTag None RunTime.Win
}

let publishBinariesLinux = BuildTask.create "PublishBinariesLinux" [clean.IfNeeded; build.IfNeeded] {
let outputPath = sprintf "%s/linux-x64" publishDir
project
|> DotNet.publish (fun p ->
let standardParams = Fake.DotNet.MSBuild.CliArguments.Create ()
{
p with
Runtime = Some "linux-x64"
Configuration = DotNet.BuildConfiguration.fromString configuration
OutputPath = Some outputPath
MSBuildParams = {
standardParams with
Properties = [
"Version", stableVersionTag
"Platform", "x64"
"PublishSingleFile", "true"
]
}
}
)
printfn "Beware that assemblyName differs from projectName!"
publishBinaries stableVersionTag None RunTime.Linux
}

let publishBinariesMac = BuildTask.create "PublishBinariesMac" [clean.IfNeeded; build.IfNeeded] {
let outputPath = sprintf "%s/osx-x64" publishDir
project
|> DotNet.publish (fun p ->
let standardParams = Fake.DotNet.MSBuild.CliArguments.Create ()
{
p with
Runtime = Some "osx-x64"
Configuration = DotNet.BuildConfiguration.fromString configuration
OutputPath = Some outputPath
MSBuildParams = {
standardParams with
Properties = [
"Version", stableVersionTag
"Platform", "x64"
"PublishSingleFile", "true"
]
}
}
)
printfn "Beware that assemblyName differs from projectName!"
publishBinaries stableVersionTag None RunTime.Mac
}

let publishBinariesMacARM = BuildTask.create "PublishBinariesMacARM" [clean.IfNeeded; build.IfNeeded] {
let outputPath = sprintf "%s/osx-arm64" publishDir
project
|> DotNet.publish (fun p ->
let standardParams = Fake.DotNet.MSBuild.CliArguments.Create ()
{
p with
Runtime = Some "osx.12-arm64"
Configuration = DotNet.BuildConfiguration.fromString configuration
OutputPath = Some outputPath
MSBuildParams = {
standardParams with
Properties = [
"Version", stableVersionTag
//"Platform", "arm64" // throws MSBuild Error although it should work: error MSB4126: The specified solution configuration "Release|ARM64" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration. [C:\Repos\omaus\arcCommander\ArcCommander.sln]
"PublishSingleFile", "true"
]
}
}
)
printfn "Beware that assemblyName differs from projectName!"
publishBinaries stableVersionTag None RunTime.MacARM
}

let publishBinariesAll = BuildTask.createEmpty "PublishBinariesAll" [clean; build; publishBinariesWin; publishBinariesLinux; publishBinariesMac; publishBinariesMacARM]

let publishBinariesMacBoth = BuildTask.createEmpty "PublishBinariesMacBoth" [clean; build; publishBinariesMac; publishBinariesMacARM]
let publishBinariesWinPrerelease = BuildTask.create "PublishBinariesWinPrerelease" [clean.IfNeeded; build.IfNeeded; setPrereleaseTag] {
publishBinaries stableVersionTag (Some prereleaseSuffix) RunTime.Win
}

let publishBinariesLinuxPrerelease = BuildTask.create "PublishBinariesLinuxPrerelease" [clean.IfNeeded; build.IfNeeded; setPrereleaseTag] {
publishBinaries stableVersionTag (Some prereleaseSuffix) RunTime.Linux
}

let publishBinariesMacPrerelease = BuildTask.create "PublishBinariesMacPrerelease" [clean.IfNeeded; build.IfNeeded; setPrereleaseTag] {
publishBinaries stableVersionTag (Some prereleaseSuffix) RunTime.Mac
}

let publishBinariesMacARMPrerelease = BuildTask.create "PublishBinariesMacARMPrerelease" [clean.IfNeeded; build.IfNeeded; setPrereleaseTag] {
publishBinaries stableVersionTag (Some prereleaseSuffix) RunTime.MacARM
}

let publishBinariesAllPrerelease = BuildTask.createEmpty "PublishBinariesAllPrerelease" [clean; build; setPrereleaseTag; publishBinariesWinPrerelease; publishBinariesLinuxPrerelease; publishBinariesMacPrerelease; publishBinariesMacARMPrerelease]



// as of now (july 2022), it seems there is now possibility to run lipo on Windows
//let packMacBinaries = BuildTask.create "PackMacBinaries" [publishBinariesMacBoth] {
68 changes: 0 additions & 68 deletions build/ReleaseTasks.fs
Original file line number Diff line number Diff line change
@@ -12,71 +12,3 @@ open Helpers
open BasicTasks
open TestTasks
open PackageTasks

let createTag = BuildTask.create "CreateTag" [clean; build; copyBinaries; runTests; pack] {
if promptYesNo (sprintf "tagging branch with %s OK?" stableVersionTag ) then
Git.Branches.tag "" stableVersionTag
Git.Branches.pushTag "" projectRepo stableVersionTag
else
failwith "aborted"
}

let createPrereleaseTag = BuildTask.create "CreatePrereleaseTag" [setPrereleaseTag; clean; build; copyBinaries; runTests; packPrerelease] {
if promptYesNo (sprintf "tagging branch with %s OK?" prereleaseTag ) then
Git.Branches.tag "" prereleaseTag
Git.Branches.pushTag "" projectRepo prereleaseTag
else
failwith "aborted"
}

let publishNuget = BuildTask.create "PublishNuget" [clean; build; copyBinaries; runTests; pack] {
let targets = (!! (sprintf "%s/*.*pkg" pkgDir ))
for target in targets do printfn "%A" target
let msg = sprintf "release package with version %s?" stableVersionTag
if promptYesNo msg then
let source = "https://api.nuget.org/v3/index.json"
let apikey = Environment.environVar "NUGET_KEY"
for artifact in targets do
let result = DotNet.exec id "nuget" (sprintf "push -s %s -k %s %s --skip-duplicate" source apikey artifact)
if not result.OK then failwith "failed to push packages"
else failwith "aborted"
}

let publishNugetPrerelease = BuildTask.create "PublishNugetPrerelease" [clean; build; copyBinaries; runTests; packPrerelease] {
let targets = (!! (sprintf "%s/*.*pkg" pkgDir ))
for target in targets do printfn "%A" target
let msg = sprintf "release package with version %s?" prereleaseTag
if promptYesNo msg then
let source = "https://api.nuget.org/v3/index.json"
let apikey = Environment.environVar "NUGET_KEY"
for artifact in targets do
let result = DotNet.exec id "nuget" (sprintf "push -s %s -k %s %s --skip-duplicate" source apikey artifact)
if not result.OK then failwith "failed to push packages"
else failwith "aborted"
}

//let releaseDocs = BuildTask.create "ReleaseDocs" [buildDocs] {
// let msg = sprintf "release docs for version %s?" stableVersionTag
// if promptYesNo msg then
// Shell.cleanDir "temp"
// Git.CommandHelper.runSimpleGitCommand "." (sprintf "clone %s temp/gh-pages --depth 1 -b gh-pages" projectRepo) |> ignore
// Shell.copyRecursive "output" "temp/gh-pages" true |> printfn "%A"
// Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s"
// let cmd = sprintf """commit -a -m "Update generated documentation for version %s""" stableVersionTag
// Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" cmd |> printfn "%s"
// Git.Branches.push "temp/gh-pages"
// else failwith "aborted"
//}

//let prereleaseDocs = BuildTask.create "PrereleaseDocs" [buildDocsPrerelease] {
// let msg = sprintf "release docs for version %s?" prereleaseTag
// if promptYesNo msg then
// Shell.cleanDir "temp"
// Git.CommandHelper.runSimpleGitCommand "." (sprintf "clone %s temp/gh-pages --depth 1 -b gh-pages" projectRepo) |> ignore
// Shell.copyRecursive "output" "temp/gh-pages" true |> printfn "%A"
// Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s"
// let cmd = sprintf """commit -a -m "Update generated documentation for version %s""" prereleaseTag
// Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" cmd |> printfn "%s"
// Git.Branches.push "temp/gh-pages"
// else failwith "aborted"
//}
16 changes: 8 additions & 8 deletions build/ToolTasks.fs
Original file line number Diff line number Diff line change
@@ -7,12 +7,12 @@ open ProjectInfo
open Helpers
open PackageTasks

let installPackagedTool = BuildTask.create "InstallPackagedTool" [packPrerelease] {
Directory.ensure "tests/tool-tests"
run dotnet "new tool-manifest --force" "tests/tool-tests"
run dotnet (sprintf "tool install --add-source ../../%s ArcCommander --version %s" pkgDir prereleaseTag) "tests/tool-tests"
}
//let installPackagedTool = BuildTask.create "InstallPackagedTool" [packPrerelease] {
// Directory.ensure "tests/tool-tests"
// run dotnet "new tool-manifest --force" "tests/tool-tests"
// run dotnet (sprintf "tool install --add-source ../../%s ArcCommander --version %s" pkgDir prereleaseTag) "tests/tool-tests"
//}

let testPackagedTool = BuildTask.create "TestPackagedTool" [installPackagedTool] {
run dotnet "ArcCommander --help" "tests/tool-tests"
}
//let testPackagedTool = BuildTask.create "TestPackagedTool" [installPackagedTool] {
// run dotnet "ArcCommander --help" "tests/tool-tests"
//}
2 changes: 1 addition & 1 deletion src/ArcCommander/APIs/ConfigurationAPI.fs
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ module ConfigurationAPI =

/// Lists all current settings specified in the configuration.
let list (arcConfiguration : ArcConfiguration) (configurationArgs : ArcParseResults<ConfigurationListArgs>) =

let log = Logging.createLogger "ConfigurationListLog"

match configurationArgs.ContainsFlag ConfigurationListArgs.Global, configurationArgs.ContainsFlag ConfigurationListArgs.Local with
2 changes: 1 addition & 1 deletion src/ArcCommander/ArcCommander.fsproj
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@
<!--References-->
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="7.0.401" />
<PackageReference Include="ARCtrl.NET" Version="1.0.0-beta.1" />
<PackageReference Include="ARCtrl.NET" Version="1.0.0-beta.2" />
<PackageReference Include="Argu" Version="6.1.1" />
<PackageReference Include="Fake.IO.FileSystem" Version="6.0.0" />
<PackageReference Include="Fake.Tools.Git" Version="6.0.0" />