diff --git a/.github/workflows/cd-production.yml b/.github/workflows/cd-production.yml
index 324dd15..a1da529 100644
--- a/.github/workflows/cd-production.yml
+++ b/.github/workflows/cd-production.yml
@@ -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 }}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7fd0bd4..e0ea0fd 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -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
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index 2868059..3a283d7 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -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:
@@ -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 }}
diff --git a/.release-it.json b/.release-it.json
index 1bd4cd6..233c8dd 100644
--- a/.release-it.json
+++ b/.release-it.json
@@ -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": {
diff --git a/CHANGELOG.md b/CHANGELOG.md
index decedcf..6b9cd59 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/GoogleSecrets.sln b/GoogleSecrets.sln
deleted file mode 100644
index 1f3c32e..0000000
--- a/GoogleSecrets.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.31515.178
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoogleSecrets", "GoogleSecrets\GoogleSecrets.csproj", "{C7B9C660-1ABC-4DAE-B7C3-DB18810D3794}"
-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
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {42F5F9A3-C6A3-414F-99A2-BC25926F751B}
- EndGlobalSection
-EndGlobal
diff --git a/GoogleSecrets/GoogleSecretsExtensions.cs b/GoogleSecrets/ConfigurationBuilderExtensions.cs
similarity index 51%
rename from GoogleSecrets/GoogleSecretsExtensions.cs
rename to GoogleSecrets/ConfigurationBuilderExtensions.cs
index fda2fef..5a78bfe 100644
--- a/GoogleSecrets/GoogleSecretsExtensions.cs
+++ b/GoogleSecrets/ConfigurationBuilderExtensions.cs
@@ -6,10 +6,32 @@
///
/// The Google Secrets Extensions
///
- public static class GoogleSecretsExtensions
+ public static class ConfigurationBuilderExtensions
{
///
- /// Adds the google secrets.
+ /// Adds the Google secrets to the .
+ /// If the GOOGLE_SECRETS_PROJECT environment variable is set, it will be used as the project name.
+ ///
+ /// The configuration.
+ /// The IConfigurationBuilder
+ /// options
+ 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, _ => { });
+ }
+
+ ///
+ /// Adds the Google secrets to the .
///
/// The configuration.
/// The options.
diff --git a/GoogleSecrets/EnvironmentVariableNames.cs b/GoogleSecrets/EnvironmentVariableNames.cs
new file mode 100644
index 0000000..14c68a9
--- /dev/null
+++ b/GoogleSecrets/EnvironmentVariableNames.cs
@@ -0,0 +1,13 @@
+namespace Neolution.Extensions.Configuration.GoogleSecrets
+{
+ ///
+ /// Contains the names of environment variables used for Google Secrets configuration.
+ ///
+ public static class EnvironmentVariableNames
+ {
+ ///
+ /// The name of the environment variable where the google secrets project id is stored.
+ ///
+ public const string GoogleSecretsProject = "GOOGLE_SECRETS_PROJECT";
+ }
+}
\ No newline at end of file
diff --git a/GoogleSecrets/GoogleSecrets.csproj b/GoogleSecrets/Neolution.Extensions.Configuration.GoogleSecrets.csproj
similarity index 86%
rename from GoogleSecrets/GoogleSecrets.csproj
rename to GoogleSecrets/Neolution.Extensions.Configuration.GoogleSecrets.csproj
index 5a11381..60937ca 100644
--- a/GoogleSecrets/GoogleSecrets.csproj
+++ b/GoogleSecrets/Neolution.Extensions.Configuration.GoogleSecrets.csproj
@@ -19,9 +19,10 @@
-
-
-
+
+
+
+
diff --git a/Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore/Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore.csproj b/Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore/Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore.csproj
new file mode 100644
index 0000000..77e9ed9
--- /dev/null
+++ b/Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore/Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net8.0
+ enable
+ enable
+ true
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore/WebApplicationBuilderExtensions.cs b/Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore/WebApplicationBuilderExtensions.cs
new file mode 100644
index 0000000..82d4dd7
--- /dev/null
+++ b/Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore/WebApplicationBuilderExtensions.cs
@@ -0,0 +1,31 @@
+namespace Neolution.Extensions.Configuration.GoogleSecrets.AspNetCore
+{
+ using System;
+ using Microsoft.AspNetCore.Builder;
+
+ ///
+ /// Google Secrets extensions for .
+ ///
+ public static class WebApplicationBuilderExtensions
+ {
+ ///
+ /// Adds the Google secrets to the .
+ /// Uses the GOOGLE_SECRETS_PROJECT environment variable as the project name.
+ ///
+ /// The builder.
+ 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;
+ });
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Neolution.Extensions.Configuration.GoogleSecrets.sln b/Neolution.Extensions.Configuration.GoogleSecrets.sln
new file mode 100644
index 0000000..2f70b2e
--- /dev/null
+++ b/Neolution.Extensions.Configuration.GoogleSecrets.sln
@@ -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