Skip to content

CI

CI #11

Workflow file for this run

name: CI
on:
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
push:
branches:
- '*' # Run the workflow for all pull requests
paths-ignore:
- README.md
pull_request:
branches:
- '*' # Run the workflow for all pull requests
release:
types:
- published # Run the workflow when a new GitHub release is published
permissions: read-all
env: # https://docs.github.com/en/actions/learn-github-actions/variables
Solution_Name: '**/*.sln'
Build_Configuration: Release
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
NuGet_Directory: ${{ github.workspace}}/nuget
defaults:
run:
shell: bash
jobs:
version:
name: Version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 8.x
- run: dotnet --info
- name: Install minver tool
run: dotnet tool install --global minver-cli --version 4.3.0
- name: Calculate version # make VERSION available as env.version
run: |
VERSION=$(minver -v d)
echo $VERSION
echo "version=$VERSION" >> "$GITHUB_ENV"
build:
name: Build & Package
runs-on: ubuntu-latest
needs: version
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Setup .NET
uses: actions/[email protected]
with:
dotnet-version: 8.x
- run: dotnet --info
- name: Restore nuget packages
run: dotnet restore --verbosity Normal
- name: Build solution
run: dotnet build ${{ env.Solution_Name }} --configuration ${{ env.Build_Configuration }} --no-restore --nologo
- name: Vulnerability scan (nuget)
run: |
dotnet list ${{ github.workspace }}/BridgingIT.DevKit.sln package --vulnerable --include-transitive 2>&1 | tee build.log
test `grep -cm 1 'has the following vulnerable packages' build.log` = 0 || exit 1
- name: Unit tests
run: dotnet test '**/*[Tt]ests/*UnitTests.csproj' --configuration ${{ env.Build_Configuration }} --no-restore --no-build --nologo
- name: Integration tests
run: dotnet test '**/*[Tt]ests/*IntegrationTests.csproj' --configuration ${{ env.Build_Configuration }} --no-restore --no-build --nologo --filter FullyQualifiedName!~Examples
# - name: Package pack (nuget)
# run: dotnet pack --configuration ${{ env.Build_Configuration }} --no-restore --no-build --nologo ${{ env.Solution_Name }} --no-build --output ${{ env.NuGet_Directory }}
# - name: Package push (nuget) # Push only when creating a GitHub Release
# env:
# SOURCE: ${{ secrets.NUGET_PUSH_SOURCE }} # https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions
# API_KEY: ${{ secrets.NUGET_PUSH_API_KEY }}
# if: github.event_name == 'release' && (env.SOURCE != '' || env.API_KEY != '')
# run: dotnet nuget push ${{ env.NuGet_Directory }}/*.nupkg --source ${{ env.SOURCE }} --api-key ${{ env.API_KEY }}
# - name: Publish package artifacts
# uses: actions/[email protected]
# with:
# name: NuGet packages
# if-no-files-found: error
# retention-days: 7
# path: ${{ env.NuGet_Directory }}/*.nupkg