1- #addin nuget : ? package= Cake . Git & version = 4.0 .0
1+ #addin nuget : ? package= Cake . Git & version = 5.0 .1
2+ #addin nuget: ? package = Cake . GitHub & version = 1.0 .0
23#tool nuget: ? package = NuGet . CommandLine & version = 6.9 .1
34
45using System;
@@ -26,6 +27,7 @@ var preRelease = Argument("pre-release", false);
2627var username = Argument ( "username" , "NaBian" ) ;
2728var email = Argument ( "email" , "[email protected] " ) ; 2829var nugetToken = Argument ( "nuget-token" , "" ) ;
30+ var githubToken = Argument ( "github-token" , "" ) ;
2931
3032var libVersion = "" ;
3133var nugetVersion = "" ;
@@ -127,13 +129,14 @@ Task("commit files")
127129
128130 var exitCode = StartProcess (
129131 "git" ,
130- new ProcessSettings {
132+ new ProcessSettings
133+ {
131134 Arguments = "diff --cached --quiet" ,
132135 WorkingDirectory = gitRootPath
133136 }
134137 ) ;
135-
136- if ( exitCode == 0 )
138+
139+ if ( exitCode == 0 )
137140 {
138141 Information ( "no change." ) ;
139142 return ;
@@ -345,6 +348,33 @@ Task("push to nuget")
345348 } ) ;
346349} ) ;
347350
351+ Task ( "create github release" )
352+ . Does ( async ( ) =>
353+ {
354+ await GitHubCreateReleaseAsync (
355+ /// The user name to use for authentication (pass null when using an access token).
356+ userName : null ,
357+ /// The access token or password to use for authentication.
358+ apiToken : githubToken ,
359+ // The owner (user or group) of the repository to create a release in.
360+ owner : "HandyOrg" ,
361+ /// The name of the repository to create a release in.
362+ repository : "HandyControl" ,
363+ /// The name of the tag to create a release for.
364+ /// If the tag does not yet exist, a new tag will be created (using either the HEAD of the default branch or the commit specified in the settings).
365+ /// If the tag already exists, the existing tag will be used and the commit specified in the settings will be ignored.
366+ tagName : $ "v{ nugetVersion } ",
367+ settints : new GitHubCreateReleaseSettings
368+ {
369+ ReleaseName = $ "Release v{ nugetVersion } ",
370+ Body = ReadAllText ( Combine ( buildConfig . OutputsFolder , "CHANGELOG.md" ) , Encoding . UTF8 ) ,
371+ Prerelease = preRelease ,
372+ Overwrite = false ,
373+ Assets = GetFiles ( "../build/outputs/installer/net40/*" ) . ToArray ( ) ,
374+ }
375+ ) ;
376+ } ) ;
377+
348378Task ( "publish" )
349379 . IsDependentOn ( "update license" )
350380 . IsDependentOn ( "update version" )
@@ -362,6 +392,7 @@ Task("publish")
362392 . IsDependentOn ( "pack nuspec files" )
363393 . IsDependentOn ( "create demo installers" )
364394 . IsDependentOn ( "push to nuget" )
395+ . IsDependentOn ( "create github release" )
365396 ;
366397
367398Task ( "build" )
0 commit comments