Skip to content

Update upload-artifact action to version 4 #53

Update upload-artifact action to version 4

Update upload-artifact action to version 4 #53

Workflow file for this run

# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET CI/CD
on:
push:
branches: [ "main", "legacy-1.0", "experimental" ]
tags: [ "v*" ]
pull_request:
branches: [ "main", "legacy-1.0", "experimental" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
configuration: [Debug, Release]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for GitVersion
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Determine Version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
elif [[ "${{ github.ref_name }}" == "main" ]]; then
VERSION="2.0.0"
elif [[ "${{ github.ref_name }}" == "legacy-1.0" ]]; then
VERSION="1.0.0"
elif [[ "${{ github.ref_name }}" == "experimental" ]]; then
VERSION="3.0.0-alpha"
else
VERSION="0.0.0-dev"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration ${{ matrix.configuration }} -p:Version=${{ steps.version.outputs.version }}
- name: Test
run: dotnet test --no-build --configuration ${{ matrix.configuration }} --verbosity normal --collect:"XPlat Code Coverage"
- name: Upload coverage reports
if: matrix.configuration == 'Release'
uses: codecov/codecov-action@v3
with:
files: '**/coverage.cobertura.xml'
fail_ci_if_error: false
package:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Determine Version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION="2.0.0"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create NuGet Package
run: dotnet pack --configuration Release -p:Version=${{ steps.version.outputs.version }} --output ./packages
- name: Upload Package Artifacts
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: ./packages/*.nupkg