Skip to content

17 add createdby modifiedby deletedby in securedentity #12

17 add createdby modifiedby deletedby in securedentity

17 add createdby modifiedby deletedby in securedentity #12

name: NuGet CI/CD
on:
pull_request:
branches:
- main
paths:
- .github/workflows/gtc-domain-nuget.yml
- src/**
push:
branches:
- main
paths:
- .github/workflows/gtc-domain-nuget.yml
- src/**
workflow_dispatch:
inputs:
environment:
description: "Environment to run"
required: true
default: "development"
permissions:
id-token: write
contents: read
security-events: write
env:
SCRIPTS_PATH: "./.github/scripts"
SRC_PATH: "./src"
PROJECT_PATH: "Goodtocode.Domain"
PROJECT_FILE: "Goodtocode.Domain.csproj"
SRC_SLN: "Goodtocode.Domain.sln"
TEST_PATH: "Goodtocode.Domain.Tests"
TEST_PROJECT: "Goodtocode.Domain.Tests.csproj"
jobs:
ci:
name: "NuGet CI"
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' || github.event_name == 'push'
environment: development
strategy:
matrix:
DOTNET_VERSION: ["10.x"]
env:
RUNTIME_ENV: "Development"
steps:
- name: checkout
uses: actions/checkout@v3
- name: dotnet version ${{ matrix.DOTNET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.DOTNET_VERSION }}
- name: Get Semantic Version
id: get_semver
run: |
$json = & "${{ env.SCRIPTS_PATH }}/ci/Get-Version.ps1" -Major 1 -Minor 1 -Patch $env:GITHUB_RUN_NUMBER
$semver = ($json | ConvertFrom-Json).SemanticVersion
echo "SEMANTIC_VERSION=$semver" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Set-Version.ps1
run: |
$version = ${{ env.SCRIPTS_PATH }}/ci/Set-Version.ps1 -Path ${{ env.SRC_PATH }} -VersionToReplace 1.0.0 -Major 1 -Minor 1
echo $version
echo "VERSION=$version" >> $GITHUB_ENV
shell: pwsh
- name: pipeline environment configuration
run: |
echo "ASPNETCORE_ENVIRONMENT=${{ env.RUNTIME_ENV }}" >> $GITHUB_ENV
shell: pwsh
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: csharp
- name: Build
run: |
dotnet build ${{ env.SRC_PATH }}/${{ env.SRC_SLN }} --configuration Release
shell: pwsh
- name: Test
run: |
mkdir -p TestResults-${{ matrix.DOTNET_VERSION }}
dotnet test ${{ env.SRC_PATH }}/${{ env.TEST_PATH }}/${{ env.TEST_PROJECT }} --results-directory TestResults-${{ matrix.DOTNET_VERSION }} --collect:"Code Coverage" --verbosity normal
shell: pwsh
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: dotnet-results-${{ matrix.DOTNET_VERSION }}
path: TestResults-${{ matrix.DOTNET_VERSION }}
if: ${{ always() }}
- name: Pack NuGet package
run: |
dotnet pack ${{ env.SRC_PATH }}/${{ env.PROJECT_PATH }}/${{ env.PROJECT_FILE }} --configuration Release --no-build --output nupkg_output --version ${{ steps.get_semver.outputs.SEMANTIC_VERSION }}
shell: pwsh
- name: Upload NuGet package artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: nupkg_output/*.nupkg
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
cd:
name: "NuGet CD"
runs-on: ubuntu-latest
needs: ci
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment: production
strategy:
matrix:
DOTNET_VERSION: ["10.x"]
env:
NUGET_OUTPUT: "nupkg_output"
steps:
- name: Download NuGet package artifact
uses: actions/download-artifact@v4
with:
name: nuget-package
path: nupkg_output
- name: Publish to NuGet.org
run: |
dotnet nuget push nupkg_output/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate