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
8 changes: 4 additions & 4 deletions .github/workflows/cd-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ jobs:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY_NEOLUTION }}

- name: Determine version for NuGet package
run: echo NUGET_VERSION=${GITHUB_REF#refs/tags/v} >> $GITHUB_ENV
run: echo NUGET_VERSION=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV

- name: Build and pack
run: |
dotnet restore
dotnet build --configuration ${{ env.BUILD_CONFIGURATION }} -p:Version=$NUGET_VERSION
dotnet pack --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore --no-build -p:PackageVersion=$NUGET_VERSION
dotnet build --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore -p:Version=$NUGET_VERSION
dotnet pack --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --no-restore -p:PackageVersion=$NUGET_VERSION

- name: Push NuGet package
run: echo "dotnet nuget push -k $NUGET_AUTH_TOKEN **/bin/Release/*.nupkg"
run: dotnet nuget push -k $NUGET_AUTH_TOKEN **/bin/Release/*.nupkg
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY_NEOLUTION }}
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ jobs:

- uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.x
dotnet-version: 8.x

- run: dotnet build -c Release

- run: dotnet pack -c Release --no-build --no-restore -o ./artifacts

- run: mv ./artifacts/*.nupkg ./artifacts/Neolution.Extensions.Configuration.GoogleSecrets.${{ github.run_id }}-${{ github.run_attempt }}.nupkg
- run: dotnet pack -c Release --no-build --no-restore -o ./artifacts -p:PackageVersion=$(date -d "${GITHUB_RUN_TIMESTAMP}" "+%Y.%-m.%-d")-ci.${{ github.run_attempt }}${{ github.run_id }}

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
47 changes: 28 additions & 19 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,29 @@ name: Create Release
on:
workflow_dispatch:
inputs:
version_type:
versioning_phase:
type: choice
description: Semantic Version Type
description: Versioning Phase
default: stable
options:
- automatic
- alpha
- beta
- rc
- stable

bump_version_number:
type: choice
description: Bump Version Number
default: consecutive
options:
- consecutive
- patch
- minor
- major

pre_release:
type: choice
description: Stage
options:
- stable
- rc
- beta
- alpha
is_dry_run:
type: boolean
description: Dry Run

jobs:
release-it:
Expand All @@ -43,27 +49,30 @@ jobs:
git config user.name "GitHub Release Bot"
git config user.email release-bot@neolution.ch

- name: install @release-it/keep-a-changelog
run: yarn add release-it @release-it/keep-a-changelog @neolution-ch/release-it-dotnet-plugin
- name: install release-it with plugins
run: npm install -g release-it @release-it/keep-a-changelog

- name: run release-it
run: |
params=()

if [[ ${{ github.event.inputs.version_type }} != "automatic" ]]; then
params+=(${{ github.event.inputs.version_type }})
if [[ ${{ github.event.inputs.bump_version_number }} != "consecutive" ]]; then
params+=(${{ github.event.inputs.bump_version_number }})
fi

if [[ ${{ github.event.inputs.pre_release }} != "stable" ]]; then
params+=(--preRelease=${{ github.event.inputs.pre_release }})
if [[ ${{ github.event.inputs.versioning_phase }} != "stable" ]]; then
params+=(--preRelease=${{ github.event.inputs.versioning_phase }})
params+=(--plugins.@release-it/keep-a-changelog.keepUnreleased)
params+=(--no-plugins.@release-it/keep-a-changelog.strictLatest)
fi

if [[ ${{ github.event.inputs.is_dry_run }} == "true" ]]; then
params+=(--dry-run)
fi

params+=(--ci)
params+=(--plugins.@neolution-ch/release-it-dotnet-plugin.nugetApiKey=${{ secrets.NUGET_API_KEY_NEOLUTION }})

echo "command: release-it ${params[@]}"
yarn release-it "${params[@]}"
release-it "${params[@]}"
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
5 changes: 0 additions & 5 deletions .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
"addVersionUrl": true,
"addUnreleased": true,
"strictLatest": false
},
"@neolution-ch/release-it-dotnet-plugin": {
"csprojFile": "./GoogleSecrets/GoogleSecrets.csproj",
"buildConfiguration": "Release",
"nugetApiKey": "overridden in GitHub workflow"
}
},
"hooks": {
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ and adheres to a project-specific [Versioning](/README.md).

## [Unreleased]

### Dependabot
### Added

- Convention to load Google Secrets project name from environment variable `GOOGLE_SECRETS_PROJECT` if not specified in the options.
- New package `Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore` to reference in ASP.NET Core projects.

### Changed

- Update GitHub Actions to use the latest versions of the actions

Expand Down
25 changes: 0 additions & 25 deletions GoogleSecrets.sln

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,32 @@
/// <summary>
/// The Google Secrets Extensions
/// </summary>
public static class GoogleSecretsExtensions
public static class ConfigurationBuilderExtensions
{
/// <summary>
/// Adds the google secrets.
/// Adds the Google secrets to the <see cref="ConfigurationBuilder"/>.
/// If the GOOGLE_SECRETS_PROJECT environment variable is set, it will be used as the project name.
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <returns>The IConfigurationBuilder</returns>
/// <exception cref="System.ArgumentNullException">options</exception>
public static IConfigurationBuilder AddGoogleSecrets(this IConfigurationBuilder configuration)
{
// Configure app configuration to add Google Secrets if environment variable is set
var googleSecretProject = Environment.GetEnvironmentVariable(EnvironmentVariableNames.GoogleSecretsProject);
if (!string.IsNullOrWhiteSpace(googleSecretProject))
{
return AddGoogleSecrets(configuration, options =>
{
options.ProjectName = googleSecretProject;
});
}

return AddGoogleSecrets(configuration, _ => { });
}

/// <summary>
/// Adds the Google secrets to the <see cref="ConfigurationBuilder"/>.
/// </summary>
/// <param name="configuration">The configuration.</param>
/// <param name="options">The options.</param>
Expand Down
13 changes: 13 additions & 0 deletions GoogleSecrets/EnvironmentVariableNames.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Neolution.Extensions.Configuration.GoogleSecrets
{
/// <summary>
/// Contains the names of environment variables used for Google Secrets configuration.
/// </summary>
public static class EnvironmentVariableNames
{
/// <summary>
/// The name of the environment variable where the google secrets project id is stored.
/// </summary>
public const string GoogleSecretsProject = "GOOGLE_SECRETS_PROJECT";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

<ItemGroup>
<PackageReference Include="Google.Cloud.SecretManager.V1" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GoogleSecrets\Neolution.Extensions.Configuration.GoogleSecrets.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore
{
using System;
using Microsoft.AspNetCore.Builder;

/// <summary>
/// Google Secrets extensions for <see cref="WebApplicationBuilder"/>.
/// </summary>
public static class WebApplicationBuilderExtensions
{
/// <summary>
/// Adds the Google secrets to the <see cref="WebApplicationBuilder"/>.
/// Uses the GOOGLE_SECRETS_PROJECT environment variable as the project name.
/// </summary>
/// <param name="builder">The builder.</param>
public static void AddGoogleSecrets(this WebApplicationBuilder builder)
{
ArgumentNullException.ThrowIfNull(builder);

// Configure app configuration to add Google Secrets if environment variable is set
var googleSecretProject = Environment.GetEnvironmentVariable(EnvironmentVariableNames.GoogleSecretsProject);
if (!string.IsNullOrWhiteSpace(googleSecretProject))
{
builder.Configuration.AddGoogleSecrets(options =>
{
options.ProjectName = googleSecretProject;
});
}
}
}
}
40 changes: 40 additions & 0 deletions Neolution.Extensions.Configuration.GoogleSecrets.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neolution.Extensions.Configuration.GoogleSecrets", "GoogleSecrets\Neolution.Extensions.Configuration.GoogleSecrets.csproj", "{C7B9C660-1ABC-4DAE-B7C3-DB18810D3794}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore", "Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore\Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore.csproj", "{19D5426C-AF24-4CE1-9BD3-BEE2B77DD56B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1A2F8802-860F-46EC-AE98-50D47A74FA91}"
ProjectSection(SolutionItems) = preProject
.github\workflows\cd-production.yml = .github\workflows\cd-production.yml
CHANGELOG.md = CHANGELOG.md
.github\workflows\ci.yml = .github\workflows\ci.yml
.github\workflows\create-release.yml = .github\workflows\create-release.yml
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C7B9C660-1ABC-4DAE-B7C3-DB18810D3794}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7B9C660-1ABC-4DAE-B7C3-DB18810D3794}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7B9C660-1ABC-4DAE-B7C3-DB18810D3794}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7B9C660-1ABC-4DAE-B7C3-DB18810D3794}.Release|Any CPU.Build.0 = Release|Any CPU
{19D5426C-AF24-4CE1-9BD3-BEE2B77DD56B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19D5426C-AF24-4CE1-9BD3-BEE2B77DD56B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19D5426C-AF24-4CE1-9BD3-BEE2B77DD56B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19D5426C-AF24-4CE1-9BD3-BEE2B77DD56B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {42F5F9A3-C6A3-414F-99A2-BC25926F751B}
EndGlobalSection
EndGlobal