Skip to content

Initial commit

Initial commit #1

Workflow file for this run

name: CI/CD
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
release:
types: [ published ]
jobs:
# CI Job - runs on every push and PR
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run tests
run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage"
- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: success()
with:
files: '**/coverage.cobertura.xml'
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
# CD Job - runs only on release
publish:
runs-on: ubuntu-latest
needs: build-and-test
if: github.event_name == 'release'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run tests
run: dotnet test --configuration Release --no-build --verbosity normal
- name: Extract version from tag
id: get_version
run: |
# Remove 'v' prefix if present
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Package version: $VERSION"
- name: Pack
run: dotnet pack src/Intervals.NET/Intervals.NET.csproj --configuration Release --no-build --output ./artifacts /p:PackageVersion=${{ steps.get_version.outputs.VERSION }}
- name: Push to NuGet
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-package-${{ steps.get_version.outputs.VERSION }}
path: ./artifacts/*.nupkg