Skip to content

Commit

Permalink
Create tar.gz and zip packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Byrd committed Sep 9, 2018
1 parent b385af5 commit e0352c3
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 79 deletions.
70 changes: 29 additions & 41 deletions Content/Console/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ module dotnet =
let reportgenerator optionConfig args =
tool optionConfig "reportgenerator" args

let sourcelink optionConfig args =
tool optionConfig "sourcelink" args



Target.create "Clean" <| fun _ ->
["bin"; "temp" ; distDir; coverageReportDir]
Expand Down Expand Up @@ -114,7 +110,6 @@ Target.create "DotnetBuild" <| fun ctx ->
let args =
[
sprintf "/p:PackageVersion=%s" release.NugetVersion
sprintf "/p:SourceLinkCreate=%b" (isRelease ctx.Context.AllExecutingTargets)
"--no-restore"
] |> String.concat " "
DotNet.build(fun c ->
Expand Down Expand Up @@ -245,47 +240,42 @@ Target.create "AssemblyInfo" <| fun _ ->
| Vbproj -> AssemblyInfoFile.createVisualBasic ((folderName @@ "My Project") @@ "AssemblyInfo.vb") attributes
)

let runtimes = [
"linux-x64", "CreateTarball"
"osx-x64", "CreateTarball"
"win-x64", "CreateZip"
]

Target.create "DotnetPack" <| fun ctx ->
!! srcGlob
|> Seq.iter (fun proj ->
Target.create "CreatePackages" <| fun _ ->

let targetFramework = "netcoreapp2.1"
runtimes
|> Seq.iter(fun (runtime, packageType) ->
let args =
[
sprintf "/t:Restore;%s" packageType
sprintf "/p:TargetFramework=%s" targetFramework
sprintf "/p:CustomTarget=%s" packageType
sprintf "/p:RuntimeIdentifier=%s" runtime
sprintf "/p:Configuration=%s" "Release"
sprintf "/p:PackageVersion=%s" release.NugetVersion
sprintf "/p:PackageReleaseNotes=\"%s\"" (release.Notes |> String.concat "\n")
sprintf "/p:SourceLinkCreate=%b" (isRelease (ctx.Context.AllExecutingTargets))
sprintf "/p:PackagePath=%s" (distDir @@ (sprintf "%s-%s-%s" productName release.NugetVersion runtime ))
] |> String.concat " "
DotNet.pack (fun c ->
{ c with
Configuration = configuration (ctx.Context.AllExecutingTargets)
OutputPath = Some distDir
Common =
c.Common
|> DotNet.Options.withCustomParams (Some args)
}) proj
)


Target.create "SourcelinkTest" <| fun _ ->
!! distGlob
|> Seq.iter (fun nupkg ->
dotnet.sourcelink id (sprintf "test %s" nupkg)
let result =
DotNet.exec (fun opt ->
{ opt with
WorkingDirectory = mainApp }
) "msbuild" args
if result.OK |> not then
result.Errors |> Seq.iter Trace.traceError
failwith "package creation failed"
)


let isReleaseBranchCheck () =
let releaseBranch = "master"
if Git.Information.getBranchName "" <> releaseBranch then failwithf "Not on %s. If you want to release please switch to this branch." releaseBranch

Target.create "Publish" <| fun _ ->
isReleaseBranchCheck ()

Paket.push(fun c ->
{ c with
PublishUrl = "https://www.nuget.org"
WorkingDir = "dist"
}
)

Target.create "GitRelease" <| fun _ ->
isReleaseBranchCheck ()
Expand Down Expand Up @@ -325,27 +315,25 @@ Target.create "Release" ignore
// Only call Clean if DotnetPack was in the call chain
// Ensure Clean is called before DotnetRestore
"Clean" ?=> "DotnetRestore"
"Clean" ==> "DotnetPack"
"Clean" ==> "CreatePackages"

// // Only call AssemblyInfo if Publish was in the call chain
// // Ensure AssemblyInfo is called after DotnetRestore and before DotnetBuild
"DotnetRestore" ?=> "AssemblyInfo"
"AssemblyInfo" ?=> "DotnetBuild"
"AssemblyInfo" ==> "Publish"
"AssemblyInfo" ==> "CreatePackages"

"DotnetRestore"
==> "DotnetBuild"
==> "DotnetTest"
==> "GenerateCoverageReport"
==> "DotnetPack"
==> "SourcelinkTest"
==> "Publish"
==> "CreatePackages"
==> "GitRelease"
// ==> "GitHubRelease"
==> "GitHubRelease"
==> "Release"

"DotnetRestore"
==> "WatchTests"


Target.runOrDefaultWithArguments "DotnetPack"
Target.runOrDefaultWithArguments "CreatePackages"
3 changes: 1 addition & 2 deletions Content/Console/paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ source https://api.nuget.org/v3/index.json
framework: netcoreapp2.1
storage: none
clitool dotnet-mono 0.5.2
clitool dotnet-sourcelink 2.8.1
clitool dotnet-fantomas 2.8.0
clitool dotnet-reportgenerator-cli 4.0.0-rc4
nuget FSharp.Core 4.3.4
nuget Expecto 8.0.0
nuget SourceLink.Create.CommandLine 2.8.1 copy_local: true
nuget YoloDev.Expecto.TestSdk 0.5.0
nuget Microsoft.NET.Test.Sdk 15.7.2
nuget altcover 4.0.603
nuget Packaging.Targets 0.1.45

// [ FAKE GROUP ]
group Build
Expand Down
30 changes: 1 addition & 29 deletions Content/Console/paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ NUGET
Microsoft.Extensions.Configuration.Json (>= 2.1)
Microsoft.NETCore.App (>= 2.0)
SixLabors.ImageSharp.Drawing (>= 1.0.0-beta0004)
dotnet-sourcelink (2.8.1) - clitool: true
Microsoft.Extensions.CommandLineUtils (>= 1.1.1)
Microsoft.NETCore.App (>= 2.0)
Newtonsoft.Json (>= 10.0.3)
NuGet.Packaging (>= 4.4)
System.Reflection.Metadata (>= 1.5)
System.ValueTuple (>= 4.4)
Expecto (8.0)
Argu (>= 5.1)
Mono.Cecil (>= 0.10)
Expand Down Expand Up @@ -85,8 +78,6 @@ NUGET
System.Runtime.Extensions (>= 4.1)
System.Runtime.InteropServices (>= 4.1)
System.Runtime.InteropServices.RuntimeInformation (>= 4.0)
Microsoft.Extensions.CommandLineUtils (1.1.1)
NETStandard.Library (>= 1.6.1)
Microsoft.Extensions.Configuration (2.1.1)
Microsoft.Extensions.Configuration.Abstractions (>= 2.1.1)
Microsoft.Extensions.Configuration.Abstractions (2.1.1)
Expand Down Expand Up @@ -170,24 +161,7 @@ NUGET
NETStandard.Library (2.0.3)
Microsoft.NETCore.Platforms (>= 1.1)
Newtonsoft.Json (11.0.2)
NuGet.Common (4.8)
NETStandard.Library (>= 1.6.1)
NuGet.Frameworks (>= 4.8)
System.Diagnostics.Process (>= 4.3)
System.Threading.Thread (>= 4.3)
NuGet.Frameworks (4.8)
NETStandard.Library (>= 1.6.1)
NuGet.Packaging (4.8)
NETStandard.Library (>= 1.6.1)
Newtonsoft.Json (>= 9.0.1)
NuGet.Packaging.Core (>= 4.8)
System.Dynamic.Runtime (>= 4.3)
NuGet.Packaging.Core (4.8)
NETStandard.Library (>= 1.6.1)
NuGet.Common (>= 4.8)
NuGet.Versioning (>= 4.8)
NuGet.Versioning (4.8)
NETStandard.Library (>= 1.6.1)
Packaging.Targets (0.1.45)
runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3)
runtime.debian.9-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3)
runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3)
Expand Down Expand Up @@ -243,7 +217,6 @@ NUGET
SixLabors.Shapes (>= 1.0.0-beta0007)
SixLabors.Shapes (1.0.0-beta0007)
SixLabors.Core (>= 1.0.0-beta0006)
SourceLink.Create.CommandLine (2.8.1) - copy_local: true
System.AppContext (4.3)
System.Runtime (>= 4.3)
System.Buffers (4.5)
Expand Down Expand Up @@ -652,7 +625,6 @@ NUGET
System.Threading.ThreadPool (4.3)
System.Runtime (>= 4.3)
System.Runtime.Handles (>= 4.3)
System.ValueTuple (4.5)
System.Xml.ReaderWriter (4.3.1)
System.Collections (>= 4.3)
System.Diagnostics.Debug (>= 4.3)
Expand Down
4 changes: 2 additions & 2 deletions Content/Console/src/MyLib.1/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open System.Reflection
[<assembly: AssemblyFileVersionAttribute("0.1.0")>]
[<assembly: AssemblyInformationalVersionAttribute("0.1.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","bb8964b54bee133e9af64d316dc2cfee16df7f72")>]
[<assembly: AssemblyMetadataAttribute("GitHash","b385af579477bb585016a6b5204121de4a485dac")>]
do ()

module internal AssemblyVersionInformation =
Expand All @@ -20,4 +20,4 @@ module internal AssemblyVersionInformation =
let [<Literal>] AssemblyFileVersion = "0.1.0"
let [<Literal>] AssemblyInformationalVersion = "0.1.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "bb8964b54bee133e9af64d316dc2cfee16df7f72"
let [<Literal>] AssemblyMetadata_GitHash = "b385af579477bb585016a6b5204121de4a485dac"
2 changes: 1 addition & 1 deletion Content/Console/src/MyLib.1/paket.references
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FSharp.Core
SourceLink.Create.CommandLine
Argu
Packaging.Targets
4 changes: 2 additions & 2 deletions Content/Console/tests/MyLib.1.Tests/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open System.Reflection
[<assembly: AssemblyFileVersionAttribute("0.1.0")>]
[<assembly: AssemblyInformationalVersionAttribute("0.1.0")>]
[<assembly: AssemblyMetadataAttribute("ReleaseChannel","release")>]
[<assembly: AssemblyMetadataAttribute("GitHash","bb8964b54bee133e9af64d316dc2cfee16df7f72")>]
[<assembly: AssemblyMetadataAttribute("GitHash","b385af579477bb585016a6b5204121de4a485dac")>]
do ()

module internal AssemblyVersionInformation =
Expand All @@ -20,4 +20,4 @@ module internal AssemblyVersionInformation =
let [<Literal>] AssemblyFileVersion = "0.1.0"
let [<Literal>] AssemblyInformationalVersion = "0.1.0"
let [<Literal>] AssemblyMetadata_ReleaseChannel = "release"
let [<Literal>] AssemblyMetadata_GitHash = "bb8964b54bee133e9af64d316dc2cfee16df7f72"
let [<Literal>] AssemblyMetadata_GitHash = "b385af579477bb585016a6b5204121de4a485dac"
1 change: 0 additions & 1 deletion Content/Console/tools/paket.references
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
dotnet-sourcelink
dotnet-fantomas
dotnet-reportgenerator-cli
2 changes: 1 addition & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Target.create "IntegrationTests" <| fun _ ->
"-n MyCoolLib --githubUsername CoolPersonNo2", "DotnetPack"
// test for dashes in name https://github.com/dotnet/templating/issues/1168#issuecomment-364592031
"-n fsharp-data-sample --githubUsername CoolPersonNo2", "DotnetPack"
"-n MyCoolLib --githubUsername CoolPersonNo2 --outputType Console", "DotnetPack"
"-n MyCoolLib --githubUsername CoolPersonNo2 --outputType Console", "CreatePackages"
]
|> Seq.iter(fun (param, testTarget) ->
use directory = DisposableDirectory.Create()
Expand Down

0 comments on commit e0352c3

Please sign in to comment.