diff --git a/.github/workflows/build-job.yml b/.github/workflows/build-job.yml index ef21c57..faa0e6c 100644 --- a/.github/workflows/build-job.yml +++ b/.github/workflows/build-job.yml @@ -4,33 +4,54 @@ on: workflow_call: inputs: dotnet-version: - required: false + required: true type: string + use-local-projects: + required: false + type: boolean + default: false + create-nuget-package: + required: false + type: boolean + default: false jobs: build: runs-on: ubuntu-latest steps: - - name: ๐Ÿ—ƒ๏ธ Checkout - uses: actions/checkout@v4 - - - name: ๐Ÿ”ง Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: ${{ inputs.dotnet-version }} - - - name: ๐Ÿ”„ Restore - run: dotnet restore - - - name: ๐Ÿ—๏ธ Build - run: dotnet build --configuration Release --no-restore - - - name: ๐Ÿ“ฆ Pack - run: dotnet pack --configuration Release --no-build -o . - - - name: โฌ†๏ธ Upload package artifact - uses: actions/upload-artifact@v4 - with: - name: nuget-package - path: "*.nupkg" + - name: Inputs + run: | + echo "dotnet-version = ${{ inputs.dotnet-version }}" + echo "use-local-projects = ${{ inputs.use-local-projects }}" + echo "create-nuget-package = ${{ inputs.create-nuget-package }}" + + - name: ๐Ÿ—ƒ๏ธ Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: ๐Ÿ”ง Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ inputs.dotnet-version }} + + - name: ๐Ÿ”„ Restore + working-directory: src + run: dotnet restore /p:UseLocalProjects=${{ inputs.use-local-projects }} + + - name: ๐Ÿ—๏ธ Build + working-directory: src + run: dotnet build --configuration Release --no-restore /p:UseLocalProjects=${{ inputs.use-local-projects }} + + - name: ๐Ÿ“ฆ Pack + working-directory: src + run: dotnet pack --configuration Release --no-build -o . + if: ${{ inputs.create-nuget-package }} + + - name: โฌ†๏ธ Upload package artifact + uses: actions/upload-artifact@v4 + if: ${{ inputs.create-nuget-package }} + with: + name: nuget-package + path: "src/${{ github.event.repository.name }}.*.nupkg" diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml deleted file mode 100644 index 9edcd48..0000000 --- a/.github/workflows/build-release.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: ๐Ÿ—๏ธ Build - -on: - workflow_call: - inputs: - dotnet-version: - required: false - type: string - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: ๐Ÿ—ƒ๏ธ Checkout - uses: actions/checkout@v4 - - - name: ๐Ÿ”ง Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: ${{ inputs.dotnet-version }} - - - name: ๐Ÿ”„ Restore - run: dotnet restore - - - name: ๐Ÿ—๏ธ Build - run: dotnet build --configuration Release --no-restore - - - name: ๐Ÿ“ฆ Pack - run: dotnet pack --configuration Release --no-build -o ./artifacts - - - name: โฌ†๏ธ Upload package artifact - uses: actions/upload-artifact@v4 - with: - name: nuget-package - path: artifacts/*.nupkg diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6eb0c41..edbf708 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,22 +12,27 @@ permissions: pull-requests: write jobs: - validate-version: - name: ๐Ÿง Validate Version - uses: ./.github/workflows/validate-version-job.yml - if: startsWith(github.ref, 'refs/tags/') build: name: ๐Ÿ—๏ธ Build Nuget Package uses: ./.github/workflows/build-job.yml with: - dotnet-version: '10.0.x' + dotnet-version: "10.0.x" + use-local-projects: false + create-nuget-package: true + + test: + name: โœ… Run Tests + uses: ./.github/workflows/test-job.yml + needs: [build] + with: + dotnet-version: "10.0.x" publish-nuget: name: ๐Ÿ“ฆ Publish Nuget Package uses: ./.github/workflows/publish-nuget-job.yml - needs: [build, validate-version] + needs: [test] if: startsWith(github.ref, 'refs/tags/') with: - dotnet-version: '10.0.x' + dotnet-version: "10.0.x" secrets: inherit diff --git a/.github/workflows/publish-nuget-job.yml b/.github/workflows/publish-nuget-job.yml index c3f44ca..4330389 100644 --- a/.github/workflows/publish-nuget-job.yml +++ b/.github/workflows/publish-nuget-job.yml @@ -4,32 +4,37 @@ on: workflow_call: inputs: dotnet-version: - required: false + required: true type: string jobs: publish-nuget: runs-on: ubuntu-latest steps: + - name: Inputs + run: | + echo "dotnet-version = ${{ inputs.dotnet-version }}" + - name: โœ… Ensure NuGet API key is present run: | if [ -z "${{ secrets.NUGET_API_KEY }}" ]; then echo "NUGET_API_KEY secret is missing. Did you forget 'secrets: inherit' in the caller workflow?" exit 1 fi - - - name: โฌ‡๏ธ Download package artifact - uses: actions/download-artifact@v4 - with: - name: nuget-package - path: . - name: ๐Ÿ”ง Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ inputs.dotnet-version }} + + - name: โฌ‡๏ธ Download package artifact + uses: actions/download-artifact@v4 + with: + name: nuget-package + path: src - name: ๐Ÿšš Publishing NuGet + working-directory: src env: NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }} - run: dotnet nuget push *.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json \ No newline at end of file + run: dotnet nuget push ${{ github.event.repository.name }}.*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json \ No newline at end of file diff --git a/.github/workflows/scripts/Check-Version.ps1 b/.github/workflows/scripts/Check-Version.ps1 deleted file mode 100644 index d493342..0000000 --- a/.github/workflows/scripts/Check-Version.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -param( - [string]$FilePath, - [string]$ExpectedVersion -) - -if (-not (Test-Path -Path $FilePath)) { - Write-Output "File not found: $FilePath" - exit 1 -} - -[xml]$xml = Get-Content -Path $FilePath -$node = $xml.SelectSingleNode("//Project/PropertyGroup/Version") - -if ($null -ne $node) { - $version = $node.InnerText - - if ($null -ne $ExpectedVersion -and $version -ne $ExpectedVersion) { - Write-Output "โŒ Version mismatch:" - Write-Output " Expected: $ExpectedVersion" - Write-Output " Found: $version" - exit 1 - } else { - Write-Output "โœ… Version found: $version" - } -} else { - Write-Output "โŒ Version not found in $FilePath" - exit 1 -} \ No newline at end of file diff --git a/.github/workflows/test-job.yml b/.github/workflows/test-job.yml new file mode 100644 index 0000000..115bf8d --- /dev/null +++ b/.github/workflows/test-job.yml @@ -0,0 +1,90 @@ +on: + workflow_call: + inputs: + dotnet-version: + required: true + type: string + use-local-projects: + required: false + type: boolean + default: false + +jobs: + discover: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.discover.outputs.matrix }} + + steps: + - name: Inputs + run: | + echo "dotnet-version = ${{ inputs.dotnet-version }}" + echo "use-local-projects = ${{ inputs.use-local-projects }}" + + - name: ๐Ÿ—ƒ๏ธ Checkout + uses: actions/checkout@v4 + + - name: ๐Ÿ”ง Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ inputs.dotnet-version }} + + - name: ๐Ÿ”Ž Find all .NET test projects + id: discover + run: | + projects=$(find . -name "*Tests.csproj" -o -name "*.Test.csproj" -o -name "*.Tests.csproj") + arr=() + for project in $projects; do + filename=$(basename "$project") + name="${filename%.csproj}" # remove .csproj + workingDirectory=$(dirname "$project") + items+=("{\"name\":\"$name\",\"path\":\"$project\",\"workingDirectory\":\"$workingDirectory\"}") + done + + json="[$(IFS=,; echo "${items[*]}")]" + + echo "Found test projects: $json" + echo "matrix={\"project\":$json}" >> $GITHUB_OUTPUT + + run: + needs: discover + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.discover.outputs.matrix) }} + + name: ${{ matrix.project.name }} + + steps: + - name: ๐Ÿ—ƒ๏ธ Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: ๐Ÿ”ง Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ inputs.dotnet-version }} + + - name: ๐Ÿ”„ Restore + working-directory: "${{ matrix.project.workingDirectory }}" + run: dotnet restore + + - name: ๐Ÿƒโ€โ™‚๏ธโ€โžก๏ธ Run Test + working-directory: "${{ matrix.project.workingDirectory }}" + run: | + dotnet run \ + --configuration Release \ + --no-restore \ + /p:SolutionDir="${{ github.workspace }}/" \ + /p:UseLocalProjects=${{ inputs.use-local-projects }} \ + -- \ + --report-trx \ + --report-trx-filename ${{ matrix.project.name }}.Results.trx \ + --results-directory ${{ matrix.project.workingDirectory }} + + - name: ๐Ÿ“ค Upload Results + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.project.name }} Test Results + path: "${{ matrix.project.workingDirectory }}/**/${{ matrix.project.name }}.Results.trx" diff --git a/.github/workflows/validate-version-job.yml b/.github/workflows/validate-version-job.yml deleted file mode 100644 index 3c9f722..0000000 --- a/.github/workflows/validate-version-job.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Validate Version - -on: - workflow_call: - -jobs: - validate-version: - runs-on: ubuntu-latest - steps: - - name: ๐Ÿ—ƒ๏ธ Checkout - uses: actions/checkout@v4 - - - name: ๐Ÿง Checking Project Version - id: csproj - shell: pwsh - run: | - $version = .github/workflows/scripts/Check-Version.ps1 -FilePath "Directory.Build.props" -ExpectedVersion $env:GITHUB_REF_NAME - - \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index 7328adf..90979a1 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,55 +1,55 @@ - - - net10.0 - + + + net10.0 + - {{Author}} - {{Description}} - {{Tags}} - {{ProjectUrl}} - {{RepositoryUrl}} + Wolf Bublitz + An extensible configuration system that allows for layering of configuration sources, enabling dynamic and flexible configuration management in applications. + Configuration + https://github.com/WB-Tooling/WB.Configuration + https://github.com/WB-Tooling/WB.Configuration git - - - 1.0.0 - + + + 1.0.0 + - - - true - true - + + + true + true + - - - portable - true - true - + + + portable + true + true + - - - latest - enable - nullable - + + + latest + enable + nullable +