Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
78 changes: 78 additions & 0 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Samples Dev Staging Deployment Script

on:
pull_request:
branches: [ "main" ]
workflow_dispatch:
concurrency:
group: samples
cancel-in-progress: true

jobs:
build:
runs-on: [ ubuntu-latest ]
timeout-minutes: 90
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.x

- name: Ensure wasm tools are installed
run: dotnet workload install wasm-tools

# Add appsettings.json to apps
- name: Add appsettings.json
shell: pwsh
run: |
dotnet ./samples/build-tools/linux-x64/BuildAppSettings.dll `
-k "${{ secrets.ARCGISAPIKEY }}" `
-l "${{ secrets.SAMPLES_GEOBLAZOR_DEV_LICENSE_KEY }}" `
-b "${{ secrets.SAMPLES_API_BYPASS_KEY }}" `
-o "./samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp.Client/wwwroot/appsettings.json" `
-o "./samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp.Client/wwwroot/appsettings.Production.json" `
-o "./samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp/appsettings.json" `
-o "./samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp/appsettings.Production.json"

# Publishes the Samples project
# DON'T PRE-RESTORE, PRE-BUILD, IT BREAKS IN DOCKER -- SEE https://github.com/dotnet/aspnetcore/issues/63962
- name: Publish Samples
shell: pwsh
run: |
dotnet publish ./samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp.csproj `
-c Release `
/p:RunAOT=true `
/m `
--output samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp/published

- name: Upload Samples Artifacts
uses: actions/upload-artifact@v4
with:
name: dev-webapp
path: samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp/published

# This step will deploy the Pro Blazor Samples app to Azure develop slot
deploy:
runs-on: [ ubuntu-latest ]
needs: [ build ]
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: dev-webapp
path: published
- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.DY_GEOBLAZOR_AZURE_DEPLOY_ID }}
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v3
with:
app-name: dy-blazor-samples-server
package: published
slot-name: develop
startup-command: 'dotnet dymaptic.GeoBlazor.Pro.Sample.WebApp.dll'
77 changes: 77 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Samples Production Release Deployment Script

on:
push:
branches: [ "main" ]
workflow_dispatch:

jobs:
build:
runs-on: [ ubuntu-latest ]
timeout-minutes: 90
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.x

- name: Ensure wasm tools are installed
run: dotnet workload install wasm-tools

# Add appsettings.json to apps
- name: Add appsettings.json
shell: pwsh
run: |
dotnet ./samples/build-tools/linux-x64/BuildAppSettings.dll `
-k "${{ secrets.ARCGISAPIKEY }}" `
-l "${{ secrets.SAMPLES_GEOBLAZOR_LICENSE_KEY }}" `
-b "${{ secrets.SAMPLES_API_BYPASS_KEY }}" `
-o "./samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp.Client/wwwroot/appsettings.json" `
-o "./samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp.Client/wwwroot/appsettings.Production.json" `
-o "./samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp/appsettings.json" `
-o "./samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp/appsettings.Production.json"

# Publishes the Samples project
# DON'T PRE-RESTORE, PRE-BUILD, IT BREAKS IN DOCKER -- SEE https://github.com/dotnet/aspnetcore/issues/63962
- name: Publish Samples
shell: pwsh
run: |
dotnet publish ./samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp.csproj `
-c Release `
--no-restore `
/p:RunAOT=true `
/m `
--output samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp/published

- name: Upload Samples Artifacts
uses: actions/upload-artifact@v4
with:
name: webapp
path: samples/pro/dymaptic.GeoBlazor.Pro.Sample.WebApp/dymaptic.GeoBlazor.Pro.Sample.WebApp/published


# This step will deploy the Pro Blazor Samples app to Azure
deploy:
runs-on: [ ubuntu-latest ]
needs: [ build ]
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: webapp
path: published
- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.DY_GEOBLAZOR_AZURE_DEPLOY_ID }}
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v3
with:
app-name: dy-blazor-samples-server
package: published
slot-name: staging
startup-command: 'dotnet dymaptic.GeoBlazor.Pro.Sample.WebApp.dll'
4 changes: 4 additions & 0 deletions samples/build-tools/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!--Empty props to override the one in the parent folder-->
</Project>
4 changes: 4 additions & 0 deletions samples/build-tools/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!--Empty props to override the one in the parent folder-->
</Project>
181 changes: 181 additions & 0 deletions samples/build-tools/build-scripts/BuildAppSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
#!/usr/bin/env dotnet

// Build AppSettings Script
// C# file-based app version of buildAppSettings.ps1
// Generates appsettings.json files for test applications.
//
// Usage: dotnet BuildAppSettings.cs [options]
// -k, --api-key <key> ArcGIS API key (required)
// -l, --license-key <key> GeoBlazor license key (required)
// -o, --output <path> Output path(s) for appsettings.json (required, can specify multiple)
// -d, --docs-url <url> Documentation URL (default: https://docs.geoblazor.com)
// -b, --bypass-key <key> API bypass key for samples (optional)
// -w, --wfs-servers <json> Additional WFS server configuration JSON fragment (optional)
// -h, --help Display help message
//
// Example:
// dotnet BuildAppSettings.cs -k "your-arcgis-key" -l "your-license" -o "./appsettings.json"
// dotnet BuildAppSettings.cs -k "key" -l "license" -o "./app1/appsettings.json" -o "./app2/appsettings.json"

using System.Text;

string? arcGISApiKey = null;
string? licenseKey = null;
List<string> outputPaths = [];
string docsUrl = "https://docs.geoblazor.com";
string byPassApiKey = "";
string wfsServers = "";
bool help = false;

// Parse command line arguments
for (int i = 0; i < args.Length; i++)
{
string arg = args[i];
switch (arg.ToLowerInvariant())
{
case "-k":
case "--api-key":
if (i + 1 < args.Length)
{
arcGISApiKey = args[++i];
}
break;
case "-l":
case "--license-key":
if (i + 1 < args.Length)
{
licenseKey = args[++i];
}
break;
case "-o":
case "--output":
if (i + 1 < args.Length)
{
outputPaths.Add(args[++i]);
}
break;
case "-d":
case "--docs-url":
if (i + 1 < args.Length)
{
docsUrl = args[++i];
}
break;
case "-b":
case "--bypass-key":
if (i + 1 < args.Length)
{
byPassApiKey = args[++i];
}
break;
case "-w":
case "--wfs-servers":
if (i + 1 < args.Length)
{
wfsServers = args[++i];
}
break;
case "-h":
case "--help":
help = true;
break;
}
}

if (help)
{
Console.WriteLine("Build AppSettings Script");
Console.WriteLine("Generates appsettings.json files for test applications.");
Console.WriteLine();
Console.WriteLine("Usage: dotnet BuildAppSettings.cs [options]");
Console.WriteLine();
Console.WriteLine("Options:");
Console.WriteLine(" -k, --api-key <key> ArcGIS API key (required)");
Console.WriteLine(" -l, --license-key <key> GeoBlazor license key (required)");
Console.WriteLine(" -o, --output <path> Output path(s) for appsettings.json (required, can specify multiple)");
Console.WriteLine(" -d, --docs-url <url> Documentation URL (default: https://docs.geoblazor.com)");
Console.WriteLine(" -b, --bypass-key <key> API bypass key for samples (optional)");
Console.WriteLine(" -w, --wfs-servers <json> Additional WFS server configuration JSON fragment (optional)");
Console.WriteLine(" -h, --help Display this help message");
Console.WriteLine();
Console.WriteLine("Examples:");
Console.WriteLine(" dotnet BuildAppSettings.cs -k \"your-arcgis-key\" -l \"your-license\" -o \"./appsettings.json\"");
Console.WriteLine(" dotnet BuildAppSettings.cs -k \"key\" -l \"license\" -o \"./app1/appsettings.json\" -o \"./app2/appsettings.json\"");
return 0;
}

// Validate required parameters
if (string.IsNullOrWhiteSpace(arcGISApiKey))
{
Console.Error.WriteLine("Error: ArcGIS API key is required. Use -k or --api-key to specify.");
return 1;
}

if (string.IsNullOrWhiteSpace(licenseKey))
{
Console.Error.WriteLine("Error: GeoBlazor license key is required. Use -l or --license-key to specify.");
return 1;
}

if (outputPaths.Count == 0)
{
Console.Error.WriteLine("Error: At least one output path is required. Use -o or --output to specify.");
return 1;
}

// Build the appsettings JSON content
var sb = new StringBuilder();
sb.AppendLine("{");
sb.AppendLine($" \"ArcGISApiKey\": \"{EscapeJsonString(arcGISApiKey)}\",");
sb.AppendLine(" \"GeoBlazor\": {");
sb.AppendLine($" \"LicenseKey\": \"{EscapeJsonString(licenseKey)}\"");
sb.AppendLine(" },");
sb.AppendLine($" \"DocsUrl\": \"{EscapeJsonString(docsUrl)}\",");
sb.Append($" \"ByPassApiKey\": \"{EscapeJsonString(byPassApiKey)}\"");

// Add WFS servers if provided
if (!string.IsNullOrWhiteSpace(wfsServers))
{
sb.AppendLine(",");
sb.Append($" {wfsServers}");
}

sb.AppendLine();
sb.AppendLine("}");

string appSettingsContent = sb.ToString();

// Write to each target path
foreach (string path in outputPaths)
{
try
{
string? directory = Path.GetDirectoryName(path);
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}

File.WriteAllText(path, appSettingsContent, Encoding.UTF8);
Console.WriteLine($"Created: {path}");
}
catch (Exception ex)
{
Console.Error.WriteLine($"Error writing to {path}: {ex.Message}");
return 1;
}
}

Console.WriteLine("AppSettings files generated successfully.");
return 0;

// Helper function to escape JSON string values
static string EscapeJsonString(string value)
{
return value
.Replace("\\", "\\\\")
.Replace("\"", "\\\"")
.Replace("\n", "\\n")
.Replace("\r", "\\r")
.Replace("\t", "\\t");
}
Loading
Loading