Skip to content

Commit

Permalink
ci: add matrix tests and separate the build job
Browse files Browse the repository at this point in the history
  • Loading branch information
cengelha committed Sep 11, 2023
1 parent c460770 commit b281ecc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
58 changes: 36 additions & 22 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,67 @@ on:
create:

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
test:
name: Test
strategy:
matrix:
framwork: [net6.0, net7.0]
os: [windows-latest, macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-quality: ga
- name: Checkout
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Unit Test
run: dotnet test libNOM.test --configuration Debug --framework ${{ matrix.framwork }}
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-quality: ga
- name: Checkout
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Dependencies
run: dotnet restore
- name: Unit Test
run: |
dotnet test libNOM.test --no-restore --configuration Debug --framework netstandard2.0
dotnet test libNOM.test --no-restore --configuration Debug --framework netstandard2.1
dotnet test libNOM.test --no-restore --configuration Debug --framework net6.0
dotnet test libNOM.test --no-restore --configuration Debug --framework net7.0
- name: Pack
run: dotnet pack libNOM.map --no-restore --configuration Release
run: dotnet pack libNOM.map --configuration Release
- name: Upload
uses: actions/upload-artifact@v3
with:
name: libNOM.map NuGet
path: libNOM.map/bin/Release/libNOM.map.*nupkg
name: NuGet
path: |
./.github/changelogs/
./libNOM.map/bin/Release/libNOM.map.*nupkg
if-no-files-found: error
release:
name: Release
runs-on: ubuntu-latest
# Only if commit was tagged.
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs: build
needs: [test, build]
steps:
# Checkout again to access the changelog.
- name: Checkout
uses: actions/checkout@v3
- name: Download
uses: actions/download-artifact@v3
with:
name: libNOM.map NuGet
name: NuGet
- name: Version
run: echo "nupkg_version=$((((Get-Item -Path .\libNOM.map.*.nupkg).Name -split '\.',3)[2] -split '\.',-2)[0])" >> $env:GITHUB_ENV
shell: pwsh
Expand All @@ -67,7 +81,7 @@ jobs:
- name: Create
uses: softprops/action-gh-release@v1
with:
body_path: ${{ github.workspace }}/.github/changelogs/${{ github.ref_name }}.md
files: libNOM.map.*nupkg
body_path: ./.github/changelogs/${{ github.ref_name }}.md
files: ./libNOM.map.*nupkg
- name: Publish
run: dotnet nuget push ./libNOM.map.*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ./libNOM.map/bin/Release/libNOM.map.*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
3 changes: 2 additions & 1 deletion libNOM.test/libNOM.test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<!-- Application -->
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<!-- Build -->
Expand Down

0 comments on commit b281ecc

Please sign in to comment.