ci: next try #60
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
echo "Building $project" | |
dotnet build "$project" --no-restore --configuration Release | |
done | |
shell: bash | |
- name: Run Tests | |
run: | | |
for project in $PROJECTS_TO_BUILD; do | |
if [[ $project == *"TEST"* ]]; then | |
echo "Running tests for $project" | |
dotnet test "$project" --no-build --verbosity normal --configuration Release | |
fi | |
done | |
shell: bash | |
- name: Pack NuGet Package | |
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 --output "./artifacts" | |
fi | |
done | |
shell: bash | |
- name: Upload NuGet Package | |
uses: actions/upload-artifact@v3 | |
with: | |
name: nuget-package | |
path: ./artifacts/*.nupkg | |
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: Download NuGet Package | |
uses: actions/download-artifact@v3 | |
with: | |
name: nuget-package | |
- name: Publish to NuGet | |
run: dotnet nuget push ./*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json |