Skip to content

add FileRsaKeyRingProvider #14

add FileRsaKeyRingProvider

add FileRsaKeyRingProvider #14

name: Build and Publish
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
permissions:
contents: read
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
SOLUTION_FILE: EfCore.EncryptedProperties.slnx
PACKAGE_PROJECT: src/EfCore.EncryptedProperties/EfCore.EncryptedProperties.csproj
PACKAGE_OUTPUT: artifacts/packages
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
outputs:
package_version: ${{ steps.package_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Read package version
id: package_version
shell: pwsh
run: |
[xml]$project = Get-Content $env:PACKAGE_PROJECT
$version = $project.Project.PropertyGroup.Version | Select-Object -First 1
if ([string]::IsNullOrWhiteSpace($version)) {
throw "Package version is missing from $env:PACKAGE_PROJECT."
}
"version=$version" >> $env:GITHUB_OUTPUT
- name: Restore
run: dotnet restore ${{ env.SOLUTION_FILE }}
- name: Test
run: dotnet test ${{ env.SOLUTION_FILE }} --configuration Release --no-restore
- name: Pack
run: dotnet pack ${{ env.PACKAGE_PROJECT }} --configuration Release --no-restore -p:ContinuousIntegrationBuild=true
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: |
${{ env.PACKAGE_OUTPUT }}/*.nupkg
${{ env.PACKAGE_OUTPUT }}/*.snupkg
if-no-files-found: error
publish:
name: Publish to NuGet
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: read
id-token: write
steps:
- name: Verify tag matches package version
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
$expected = "v${{ needs.build.outputs.package_version }}"
if ($tag -ne $expected) {
throw "Release tag '$tag' does not match package version '$expected'. Update the project <Version> or use the matching tag."
}
- name: Download packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: artifacts/packages
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: NuGet login
id: login
uses: NuGet/login@v1
with:
user: ${{ secrets.NUGET_USER }}
- name: Push package
shell: pwsh
run: |
$packages = @(Get-ChildItem -Path "artifacts/packages" -Filter "*.nupkg" -File)
if ($packages.Count -ne 1) {
$names = $packages | ForEach-Object { $_.Name } | Out-String
throw "Expected exactly one .nupkg package to publish, found $($packages.Count): $names"
}
dotnet nuget push $packages[0].FullName `
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" `
--source "https://api.nuget.org/v3/index.json" `
--symbol-source "https://api.nuget.org/v3/index.json"