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
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: build
on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
workflow_dispatch:
inputs:
forcePublish:
description: When true the Publish stage will always be run, otherwise it only runs for tagged versions.
required: false
default: false
type: boolean
forcePublicNugetDestination:
description: When true the NuGet Publish destination will always be set to nuget.org. (Normally, force publishing publishes to the private feed on GitHub.)
required: false
default: false
type: boolean

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
checks: write # enable test result annotations
contents: write # enable creating releases
issues: read
packages: write # enable publishing packages
pull-requests: write # enable test result annotations

jobs:
build:
name: Run Build
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.run_build.outputs.semver }}
major: ${{ steps.run_build.outputs.major }}
majorMinor: ${{ steps.run_build.outputs.majorMinor }}
preReleaseTag: ${{ steps.run_build.outputs.preReleaseTag }}

steps:
- uses: endjin/Endjin.RecommendedPractices.GitHubActions/actions/prepare-env-vars-and-secrets@main
id: prepareEnvVarsAndSecrets
with:
environmentVariablesYaml: |
ZF_NUGET_PUBLISH_SOURCE: ${{ (startsWith(github.ref, 'refs/tags/') || github.event.inputs.forcePublicNugetDestination == 'true') && 'https://api.nuget.org/v3/index.json' || format('https://nuget.pkg.github.com/{0}/index.json', github.repository_owner) }}
secretsYaml: |
NUGET_API_KEY: "${{ startsWith(github.ref, 'refs/tags/') && secrets.ENDJIN_NUGET_APIKEY || secrets.ENDJIN_GITHUB_PUBLISHER_PAT }}"
secretsEncryptionKey: ${{ secrets.SHARED_WORKFLOW_KEY }}

- uses: endjin/Endjin.RecommendedPractices.GitHubActions/actions/run-build-process@main
id: run_build
with:
netSdkVersion: '8.x'
# workflow_dispatch inputs are always strings, the type property is just for the UI
forcePublish: ${{ github.event.inputs.forcePublish == 'true' }}
buildEnv: ${{ steps.prepareEnvVarsAndSecrets.outputs.environmentVariablesYamlBase64 }}
buildSecrets: ${{ steps.prepareEnvVarsAndSecrets.outputs.secretsYamlBase64 }}
token: ${{ secrets.GITHUB_TOKEN }}
secretsEncryptionKey: ${{ secrets.SHARED_WORKFLOW_KEY}}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,15 @@ healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/

# Cobertura code coverage file
coverage.cobertura.xml

# Ionide (cross platform F# VS Code tools) working folder
.ionide/
/Solutions/AzAppConfigToUserSecrets.Cli/Properties/launchSettings.json

# build outputs
_codeCoverage/
_packages/
.zf/extensions/
*.sbom.*
63 changes: 63 additions & 0 deletions .zf/config.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<#
This example demonstrates a software build process using the 'ZeroFailed.Build.DotNet' extension
to provide the features needed when building a .NET solutions.
#>

$zerofailedExtensions = @(
@{
# References the extension from its GitHub repository. If not already installed, use latest version from 'main' will be downloaded.
Name = "ZeroFailed.Build.DotNet"
GitRepository = "https://github.com/zerofailed/ZeroFailed.Build.DotNet"
GitRef = "main"
}
)

# Load the tasks and process
. ZeroFailed.tasks -ZfPath $here/.zf

#
# Build process configuration
#
#
# Build process control options
#
$SkipInit = $false
$SkipVersion = $false
$SkipBuild = $false
$CleanBuild = $Clean
$SkipTest = $false
$SkipTestReport = $false
$SkipAnalysis = $false
$SkipPackage = $false

$SolutionToBuild = (Resolve-Path (Join-Path $here ".\Solutions\AzAppConfigToUserSecrets.sln")).Path
$IncludeAssembliesInCodeCoverage = "AzAppConfigToUserSecrets*"
$NugetPublishSource = property ZF_NUGET_PUBLISH_SOURCE "$here/_local-nuget-feed"
$ProjectsToPublish = @()


# Customise the build process
task . FullBuild

#
# Build Process Extensibility Points - uncomment and implement as required
#

# task RunFirst {}
# task PreInit {}
# task PostInit {}
# task PreVersion {}
# task PostVersion {}
# task PreBuild {}
# task PostBuild {}
# task PreTest {}
# task PostTest {}
# task PreTestReport {}
# task PostTestReport {}
# task PreAnalysis {}
# task PostAnalysis {}
# task PrePackage {}
# task PostPackage {}
# task PrePublish {}
# task PostPublish {}
# task RunLast {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -26,24 +26,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Data.AppConfiguration" Version="1.2.0" />
<PackageReference Include="Azure.Identity" Version="1.8.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.4.0" />
<PackageReference Include="Endjin.RecommendedPractices.GitHub" Version="2.1.12">
<PackageReference Include="Azure.Data.AppConfiguration" Version="1.6.1" />
<PackageReference Include="Azure.Identity" Version="1.14.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.7.0" />
<PackageReference Include="Endjin.RecommendedPractices.GitHub" Version="2.1.18">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Spectre.Console" Version="0.45.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine.Experimental" Version="0.3.0-alpha.19577.1" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
<PackageReference Include="System.CommandLine.Rendering" Version="0.4.0-alpha.22272.1" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Roslynator.Analyzers" Version="4.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="[8.0.*,)" />
<PackageReference Include="Spectre.Console" Version="0.50.0" />
<PackageReference Include="Spectre.Console.Cli" Version="0.50.0" />
</ItemGroup>

</Project>

107 changes: 0 additions & 107 deletions Solutions/AzAppConfigToUserSecrets.Cli/CommandLineParser.cs

This file was deleted.

38 changes: 38 additions & 0 deletions Solutions/AzAppConfigToUserSecrets.Cli/Commands/ExportCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// <copyright file="ExportCommand.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

using AzAppConfigToUserSecrets.Cli.Commands.Settings;
using AzAppConfigToUserSecrets.Cli.Handlers;
using Spectre.Console;
using Spectre.Console.Cli;

namespace AzAppConfigToUserSecrets.Cli.Commands;

/// <summary>
/// Command to export settings from Azure App Configuration to .NET User Secrets.
/// </summary>
public class ExportCommand : AsyncCommand<ExportSettings>
{
/// <summary>
/// Executes the export command.
/// </summary>
/// <param name="context">The command context.</param>
/// <param name="settings">The command settings.</param>
/// <returns>The exit code.</returns>
public override async Task<int> ExecuteAsync(CommandContext context, ExportSettings settings)
{
try
{
return await ExportHandler.ExecuteAsync(
settings.TenantId,
settings.UserSecretsId,
settings.Endpoint).ConfigureAwait(false);
}
catch (Exception ex)
{
AnsiConsole.WriteException(ex);
return 1;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// <copyright file="ExportSettings.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

using System.ComponentModel;
using Spectre.Console.Cli;

namespace AzAppConfigToUserSecrets.Cli.Commands.Settings;

/// <summary>
/// Settings for the export command.
/// </summary>
public class ExportSettings : CommandSettings
{
/// <summary>
/// Gets or sets the Azure AD Tenant ID.
/// </summary>
[CommandOption("--tenant-id")]
[Description("Id of AAD Tenant that contains your App Configuration Service")]
public required string TenantId { get; set; }

/// <summary>
/// Gets or sets the User Secrets ID.
/// </summary>
[CommandOption("--user-secrets-id")]
[Description("User Secrets Id for your application")]
public required string UserSecretsId { get; set; }

/// <summary>
/// Gets or sets the Azure App Configuration endpoint.
/// </summary>
[CommandOption("--endpoint")]
[Description("Azure Application Configuration Service endpoint (URI)")]
public required string Endpoint { get; set; }
}
Loading
Loading