44* Puerts is licensed under the BSD 3-Clause License, except for the third-party components listed in the file 'LICENSE' which may be subject to their corresponding license terms.
55* This file is subject to the terms and conditions defined in file 'LICENSE', which is part of this source code package.
66*/
7+
8+ using System ;
9+ using System . IO ;
10+ using System . Linq ;
711using Cake . Common ;
812using Cake . Common . IO ;
913using Cake . Common . Tools . DotNet ;
1216using Cake . Core . Diagnostics ;
1317using Cake . Core . IO ;
1418using Cake . Frosting ;
15- using System ;
16- using System . IO ;
17- using System . Linq ;
19+
20+ namespace Build ;
1821
1922public static class Program
2023{
@@ -40,19 +43,18 @@ public class BuildContext : FrostingContext
4043 public IDirectory ProjectsRoot => this . HasArgument ( "ProjectsRoot" )
4144 ? FileSystem . GetDirectory ( new DirectoryPath ( Arguments . GetArgument ( "ProjectsRoot" ) ) )
4245 : throw new CakeException ( $ "Argument '{ nameof ( ProjectsRoot ) } ' is required.") ;
43- public bool IsUploadPackageEnabled => this . HasArgument ( "UploadPackage" )
44- && Arguments . GetArgument ( "UploadPackage" ) . Equals ( "true" , StringComparison . OrdinalIgnoreCase ) ;
45- public string NUGET_SOURCE => this . HasEnvironmentVariable ( "NUGET_SOURCE" )
46- ? Environment . GetEnvironmentVariable ( "NUGET_SOURCE" )
47- : throw new CakeException ( "NUGET_SOURCE is not defined in environment variables" ) ;
48- public string NUGET_PUB_KEY
46+ public bool IsUploadPackageEnabled => this . HasArgument ( "Source" ) && this . HasArgument ( "ApiKey" ) ;
47+ public string Source => this . HasArgument ( "Source" )
48+ ? Arguments . GetArgument ( "Source" )
49+ : throw new CakeException ( $ "Argument '{ nameof ( Source ) } ' is required.") ;
50+ public string ApiKey
4951 {
5052 get
5153 {
52- Log . Warning ( "Accessing Secret: {0}" , nameof ( NUGET_PUB_KEY ) ) ;
53- return this . HasEnvironmentVariable ( "NUGET_PUB_KEY ")
54- ? Environment . GetEnvironmentVariable ( "NUGET_PUB_KEY ")
55- : throw new CakeException ( "NUGET_PUB_KEY is not defined in environment variables ") ;
54+ Log . Warning ( "Accessing Secret: {0}" , nameof ( ApiKey ) ) ;
55+ return this . HasArgument ( "ApiKey ")
56+ ? Arguments . GetArgument ( "ApiKey ")
57+ : throw new CakeException ( $ "Argument ' { nameof ( ApiKey ) } ' is required. ") ;
5658 }
5759 }
5860 public BuildContext ( ICakeContext context )
@@ -216,8 +218,8 @@ public override void Run(BuildContext context)
216218 new FilePath ( nugetPackageFile ) ,
217219 new Cake . Common . Tools . DotNet . NuGet . Push . DotNetNuGetPushSettings ( )
218220 {
219- Source = context . NUGET_SOURCE ,
220- ApiKey = context . NUGET_PUB_KEY
221+ Source = context . Source ,
222+ ApiKey = context . ApiKey
221223 } ) ;
222224 }
223225 }
@@ -234,14 +236,9 @@ public override void Run(BuildContext context)
234236 {
235237 context . Log . Information ( "Build and packaging completed successfully." ) ;
236238 context . Log . Information ( "Native assets have been collected and NuGet packages have been created." ) ;
237- if ( context . IsUploadPackageEnabled )
238- {
239- context . Log . Information ( "NuGet packages have been uploaded to the specified source." ) ;
240- }
241- else
242- {
243- context . Log . Information ( "Package upload is disabled. No packages were uploaded." ) ;
244- }
239+ context . Log . Information ( context . IsUploadPackageEnabled
240+ ? "NuGet packages have been uploaded to the specified source."
241+ : "Package upload is disabled. No packages were uploaded." ) ;
245242 }
246243 }
247244
@@ -265,27 +262,27 @@ public static class WellKnownProjects
265262 /// This also needs to be defined in their csproj file.
266263 /// </remarks>
267264 public static readonly ProjectAndRidWithNativeName [ ] NativeAssetsProjects =
268- [
269- new ProjectAndRidWithNativeName { Name = "Puerts.Core.NativeAssets.Win32" , DotNetRid = "win-x64" , DotNetNativeName = "Core" } ,
270- new ProjectAndRidWithNativeName { Name = "Puerts.Core.NativeAssets.Linux" , DotNetRid = "linux-x64" , DotNetNativeName = "Core" } ,
271- new ProjectAndRidWithNativeName { Name = "Puerts.Core.NativeAssets.macOS" , DotNetRid = "osx" , DotNetNativeName = "Core" } ,
272-
273- new ProjectAndRidWithNativeName { Name = "Puerts.Lua.NativeAssets.Win32" , DotNetRid = "win-x64" , DotNetNativeName = "Lua" } ,
274- new ProjectAndRidWithNativeName { Name = "Puerts.Lua.NativeAssets.Linux" , DotNetRid = "linux-x64" , DotNetNativeName = "Lua" } ,
275- new ProjectAndRidWithNativeName { Name = "Puerts.Lua.NativeAssets.macOS" , DotNetRid = "osx" , DotNetNativeName = "Lua" } ,
276-
277- new ProjectAndRidWithNativeName { Name = "Puerts.NodeJS.NativeAssets.Win32" , DotNetRid = "win-x64" , DotNetNativeName = "NodeJS" } ,
278- new ProjectAndRidWithNativeName { Name = "Puerts.NodeJS.NativeAssets.Linux" , DotNetRid = "linux-x64" , DotNetNativeName = "NodeJS" } ,
279- new ProjectAndRidWithNativeName { Name = "Puerts.NodeJS.NativeAssets.macOS" , DotNetRid = "osx" , DotNetNativeName = "NodeJS" } ,
280-
281- new ProjectAndRidWithNativeName { Name = "Puerts.QuickJS.NativeAssets.Win32" , DotNetRid = "win-x64" , DotNetNativeName = "QuickJS" } ,
282- new ProjectAndRidWithNativeName { Name = "Puerts.QuickJS.NativeAssets.Linux" , DotNetRid = "linux-x64" , DotNetNativeName = "QuickJS" } ,
283- new ProjectAndRidWithNativeName { Name = "Puerts.QuickJS.NativeAssets.macOS" , DotNetRid = "osx" , DotNetNativeName = "QuickJS" } ,
284-
285- new ProjectAndRidWithNativeName { Name = "Puerts.V8.NativeAssets.Win32" , DotNetRid = "win-x64" , DotNetNativeName = "V8" } ,
286- new ProjectAndRidWithNativeName { Name = "Puerts.V8.NativeAssets.Linux" , DotNetRid = "linux-x64" , DotNetNativeName = "V8" } ,
287- new ProjectAndRidWithNativeName { Name = "Puerts.V8.NativeAssets.macOS" , DotNetRid = "osx" , DotNetNativeName = "V8" } ,
288- ] ;
265+ [
266+ new ( ) { Name = "Puerts.Core.NativeAssets.Win32" , DotNetRid = "win-x64" , DotNetNativeName = "Core" } ,
267+ new ( ) { Name = "Puerts.Core.NativeAssets.Linux" , DotNetRid = "linux-x64" , DotNetNativeName = "Core" } ,
268+ new ( ) { Name = "Puerts.Core.NativeAssets.macOS" , DotNetRid = "osx" , DotNetNativeName = "Core" } ,
269+
270+ new ( ) { Name = "Puerts.Lua.NativeAssets.Win32" , DotNetRid = "win-x64" , DotNetNativeName = "Lua" } ,
271+ new ( ) { Name = "Puerts.Lua.NativeAssets.Linux" , DotNetRid = "linux-x64" , DotNetNativeName = "Lua" } ,
272+ new ( ) { Name = "Puerts.Lua.NativeAssets.macOS" , DotNetRid = "osx" , DotNetNativeName = "Lua" } ,
273+
274+ new ( ) { Name = "Puerts.NodeJS.NativeAssets.Win32" , DotNetRid = "win-x64" , DotNetNativeName = "NodeJS" } ,
275+ new ( ) { Name = "Puerts.NodeJS.NativeAssets.Linux" , DotNetRid = "linux-x64" , DotNetNativeName = "NodeJS" } ,
276+ new ( ) { Name = "Puerts.NodeJS.NativeAssets.macOS" , DotNetRid = "osx" , DotNetNativeName = "NodeJS" } ,
277+
278+ new ( ) { Name = "Puerts.QuickJS.NativeAssets.Win32" , DotNetRid = "win-x64" , DotNetNativeName = "QuickJS" } ,
279+ new ( ) { Name = "Puerts.QuickJS.NativeAssets.Linux" , DotNetRid = "linux-x64" , DotNetNativeName = "QuickJS" } ,
280+ new ( ) { Name = "Puerts.QuickJS.NativeAssets.macOS" , DotNetRid = "osx" , DotNetNativeName = "QuickJS" } ,
281+
282+ new ( ) { Name = "Puerts.V8.NativeAssets.Win32" , DotNetRid = "win-x64" , DotNetNativeName = "V8" } ,
283+ new ( ) { Name = "Puerts.V8.NativeAssets.Linux" , DotNetRid = "linux-x64" , DotNetNativeName = "V8" } ,
284+ new ( ) { Name = "Puerts.V8.NativeAssets.macOS" , DotNetRid = "osx" , DotNetNativeName = "V8" } ,
285+ ] ;
289286 }
290287
291288 public class ProjectAndRidWithNativeName
0 commit comments