Skip to content

Merge pull request #1 from svrooij/ci/release-events #18

Merge pull request #1 from svrooij/ci/release-events

Merge pull request #1 from svrooij/ci/release-events #18

Workflow file for this run

name: Building library
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
# strategy:
# matrix:
# dotnet-version: ['3.0', '3.1.x', '5.0.x' ]
steps:
- uses: actions/checkout@v3
# - name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
- uses: actions/cache@v3
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-restore --collect:"XPlat Code Coverage" --no-build --verbosity minimal --logger trx
- name: Test Report
uses: dorny/test-reporter@v1.6.0
if: success() || failure() # run this step even if previous step failed
with:
name: Test results # Name of the check run which will be created
path: tests/**/TestResults/*.trx # Path to test results
reporter: dotnet-trx # Format of test results
list-tests: failed # Only list failed tests vs all tests
publish:
name: Publish nuget library
runs-on: ubuntu-latest
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') && github.event_name == 'push'
needs: [build]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
- uses: actions/cache@v3
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.15
with:
versionSpec: '5.x'
- name: Determine Version
uses: gittools/actions/gitversion/execute@v0.9.15
with:
useConfigFile: true
additionalArguments: /updateprojectfiles
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Pack Sonos.Base
run: dotnet pack --configuration Release --no-build --no-restore ./src/Sonos.Base/Sonos.Base.csproj
- name: Publish Sonos.Base to nuget.org
run: dotnet nuget push ./src/Sonos.Base/bin/Release/Sonos.Base.*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
- name: Pack Sonos.Base.Events.Http
run: dotnet pack --configuration Release --no-build --no-restore ./src/Sonos.Base.Events.Http/Sonos.Base.Events.Http.csproj
- name: Publish Sonos.Base.Events.Http to nuget.org
run: dotnet nuget push ./src/Sonos.Base.Events.Http/bin/Release/Sonos.Base.*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}