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
67 changes: 44 additions & 23 deletions .github/workflows/build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
36 changes: 0 additions & 36 deletions .github/workflows/build-release.yml

This file was deleted.

19 changes: 12 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 13 additions & 8 deletions .github/workflows/publish-nuget-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
run: dotnet nuget push ${{ github.event.repository.name }}.*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
28 changes: 0 additions & 28 deletions .github/workflows/scripts/Check-Version.ps1

This file was deleted.

90 changes: 90 additions & 0 deletions .github/workflows/test-job.yml
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 0 additions & 19 deletions .github/workflows/validate-version-job.yml

This file was deleted.

Loading
Loading