Skip to content

ci: next try

ci: next try #42

Workflow file for this run

name: CI/CD Workflow
on:
push:
branches:
- main
tags:
- '*'
pull_request:
env:
PROJECTS_TO_BUILD: |
src/AspDeck/AspDeck.csproj
tests/AspDeck.Tests/AspDeck.Tests.csproj
jobs:
build-and-test:
name: Build and Test
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.x'
- name: Restore Dependencies
run: |
for project in $PROJECTS_TO_BUILD; do
echo "Restoring dependencies for $project"
dotnet restore $project
done
shell: bash
- name: Build Projects
run: |
for project in $PROJECTS_TO_BUILD; do
project_name=$(basename $project .csproj)
echo "Building $project into ./artifacts/$project_name"
dotnet build $project --no-restore --configuration Release --output ./artifacts/$project_name
done
shell: bash
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
./artifacts/
src/**/obj/
- name: Run Tests
run: |
for project in $PROJECTS_TO_BUILD; do
if [[ $project == *"TEST"* ]]; then
echo "Running tests for $project"
find ./artifacts -type f -name "*.Tests.dll" | while read file; do
echo "Testing $file"
dotnet test "$file" --no-build --verbosity normal --configuration Release
done
fi
done
shell: bash
publish:
name: Publish to NuGet
runs-on: windows-latest
needs: build-and-test
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.x'
- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Debug Downloaded Artifacts
run: |
find ./artifacts -type f
shell: bash
- name: Pack NuGet Package from Artifacts
run: |
for project in $PROJECTS_TO_BUILD; do
if [[ $project != *"TEST"* ]]; then
echo "Packing $(basename $project .csproj) from $project"
dotnet pack $project \
--no-build \
--configuration Release \
/p:PackageOutputPath="./artifacts"
else
echo "Skipping test project $project"
fi
done
shell: bash
- name: Publish to NuGet
run: dotnet nuget push ./artifacts/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json