From f6a20205502dd2d16f357994604707a5a2cbf339 Mon Sep 17 00:00:00 2001 From: Stefan Cullmann Date: Sun, 15 Sep 2019 12:27:38 +0200 Subject: [PATCH] Automate Github releases --- .gitignore | 1 + build.fsx | 29 +++++++++++++++++++++-------- paket.dependencies | 1 + paket.lock | 7 ++++++- src/Properties/AssemblyInfo.cs | 8 ++++---- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index e164610..2b2f1e8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ bin/ *.nupkg .fake/ .install/ +setEnv.ps1 diff --git a/build.fsx b/build.fsx index 1cdafb4..97c6c07 100644 --- a/build.fsx +++ b/build.fsx @@ -5,21 +5,21 @@ open Fake.IO open Fake.IO.FileSystemOperators open Fake.IO.Globbing.Operators open Fake.DotNet -open Fake.JavaScript open Fake.Core +open Fake.Api open Markdig open System.Xml //Properties -let packageName = "dnn.resx" +let packageName = "Dnn.Resx" let installDir = ".install" let buildDir = "src/bin/debug" let packageDir = installDir "package" let deployDir = installDir "deploy" let changeLogFile = "RELEASENOTES.md" let manifestFile = (sprintf "%s.dnn" packageName ) - - +let gitOwner = "scullman" +let gitName = packageName [] module Xml = @@ -65,8 +65,6 @@ Target.create "AssemblyInfo" (fun _ -> ] ) - - let copyAssemblies folder = !! (buildDir "*.dll") |> Shell.copyTo folder @@ -138,9 +136,23 @@ Target.create "PackModule" (fun _ -> createModulePackage () ) +Target.create "GitHubRelease" (fun _ -> + let token = + match Environment.environVarOrDefault "github_token" "" with + | s when not (System.String.IsNullOrWhiteSpace s) -> s + | _ -> failwith "please set the github_token environment variable to a github personal access token with repro access." -Target.create "Run" (fun _-> - Trace.trace "Running - enjoy" ) + let files = !! (installDir "*-install.zip") + + let changelog = changeLogFile |> Changelog.load + let version = changelog.LatestEntry.AssemblyVersion + let notes = [| defaultArg changelog.LatestEntry.Description "[TBD]" |] + + GitHub.createClientWithToken token + |> GitHub.draftNewRelease gitOwner gitName version true notes + |> GitHub.uploadFiles files + |> GitHub.publishDraft + |> Async.RunSynchronously) open Fake.Core.TargetOperators @@ -151,6 +163,7 @@ open Fake.Core.TargetOperators ==> "BuildServices" ==> "PackModule" ==> "Default" + ==> "GitHubRelease" // start build Target.runOrDefault "Default" \ No newline at end of file diff --git a/paket.dependencies b/paket.dependencies index c860da7..05da043 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -20,6 +20,7 @@ group Build source https://www.nuget.org/api/v2 storage:none nuget FSharp.Core + nuget Fake.Api.GitHub nuget Fake.IO.FileSystem nuget Fake.IO.Zip nuget Fake.DotNet.MsBuild diff --git a/paket.lock b/paket.lock index 1e082f2..e682667 100644 --- a/paket.lock +++ b/paket.lock @@ -7,6 +7,9 @@ NUGET BlackFox.VsWhere (1.0) - restriction: || (>= net462) (>= netstandard2.0) FSharp.Core (>= 4.0.0.1) - restriction: >= net45 FSharp.Core (>= 4.2.3) - restriction: && (< net45) (>= netstandard2.0) + Fake.Api.GitHub (5.16.1) + FSharp.Core (>= 4.7) - restriction: || (>= net462) (>= netstandard2.0) + Octokit (>= 0.32) - restriction: || (>= net462) (>= netstandard2.0) Fake.Core.CommandLineParsing (5.16.1) - restriction: || (>= net462) (>= netstandard2.0) FParsec (>= 1.0.3) - restriction: || (>= net462) (>= netstandard2.0) FSharp.Core (>= 4.7) - restriction: || (>= net462) (>= netstandard2.0) @@ -168,8 +171,10 @@ NUGET Microsoft.Build.Tasks.Core (>= 15.8.166) - restriction: && (< net46) (>= netstandard2.0) Microsoft.Build.Utilities.Core (>= 14.3) - restriction: >= net46 Microsoft.Build.Utilities.Core (>= 15.8.166) - restriction: && (< net46) (>= netstandard2.0) - NETStandard.Library (2.0.3) - restriction: || (&& (< net40) (>= net462) (>= netstandard1.6)) (&& (< net40) (>= netstandard2.0)) (>= uap10.1) + NETStandard.Library (2.0.3) - restriction: || (&& (< net40) (>= net462) (>= netstandard1.6)) (&& (< net40) (>= netstandard2.0)) (&& (< net45) (>= net462)) (&& (< net45) (>= netstandard2.0)) (>= uap10.1) Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (&& (>= net45) (< netstandard1.3)) (&& (< net45) (>= netstandard1.1) (< netstandard1.2) (< win8)) (&& (< net45) (>= netstandard1.2) (< netstandard1.3) (< win8) (< wpa81)) (&& (< net45) (>= netstandard1.3) (< netstandard1.4) (< win8) (< wpa81)) (&& (< net45) (>= netstandard1.4) (< netstandard1.5) (< win8) (< wpa81)) (&& (< net45) (>= netstandard1.5) (< netstandard1.6) (< win8) (< wpa81)) (&& (< net45) (>= netstandard1.6) (< netstandard2.0) (< win8) (< wpa81)) (&& (< net45) (>= netstandard2.0)) (&& (>= net46) (< netstandard1.4)) (>= net461) (>= netcoreapp2.0) (&& (>= netstandard1.0) (< portable-net45+win8+wpa81)) (&& (< netstandard1.0) (>= portable-net45+win8) (< win8)) (&& (< netstandard1.0) (< portable-net45+win8) (>= portable-net45+win8+wpa81)) (&& (< netstandard1.0) (>= portable-net45+win8+wp8+wpa81) (< portable-net45+win8+wpa81)) (&& (< netstandard1.0) (>= win8)) (&& (< netstandard1.3) (< win8) (>= wpa81)) (&& (< netstandard1.5) (>= uap10.0)) (>= uap10.1) (>= wp8) + Octokit (0.33) - restriction: || (>= net462) (>= netstandard2.0) + NETStandard.Library (>= 1.6) - restriction: && (< net45) (>= netstandard1.1) runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - restriction: && (< monoandroid) (< net45) (>= netstandard2.0) (< xamarinios) (< xamarinmac) runtime.debian.9-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - restriction: && (< monoandroid) (< net45) (>= netstandard2.0) (< xamarinios) (< xamarinmac) runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl (4.3.3) - restriction: && (< monoandroid) (< net45) (>= netstandard2.0) (< xamarinios) (< xamarinmac) diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs index 3f394f4..55ba802 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -2,14 +2,14 @@ // using System.Reflection; -[assembly: AssemblyProduct("dnn.resx")] -[assembly: AssemblyDescription("dnn.resx")] +[assembly: AssemblyProduct("Dnn.Resx")] +[assembly: AssemblyDescription("Dnn.Resx")] [assembly: AssemblyVersion("0.1.0")] [assembly: AssemblyFileVersion("0.1.0")] namespace System { internal static class AssemblyVersionInformation { - internal const System.String AssemblyProduct = "dnn.resx"; - internal const System.String AssemblyDescription = "dnn.resx"; + internal const System.String AssemblyProduct = "Dnn.Resx"; + internal const System.String AssemblyDescription = "Dnn.Resx"; internal const System.String AssemblyVersion = "0.1.0"; internal const System.String AssemblyFileVersion = "0.1.0"; }