Skip to content

Build

Build #433

Workflow file for this run

name: Build
on:
push:
branches: [main]
paths-ignore:
- '**/*.md'
- '**/*.gitignore'
- '**/*.gitattributes'
pull_request:
release:
types: [published]
schedule:
- cron: '0 3 * * *'
jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
scan:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Run SonarScanner
uses: highbyte/sonarscan-dotnet@v2.1.3
with:
sonarProjectKey: netboot_utility_license
sonarProjectName: Netboot Utility License
sonarHostname: https://sonarqube.netboot.fr
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: Initialize CodeQL
if: github.ref == 'refs/heads/main'
uses: github/codeql-action/init@v2
with:
languages: 'csharp'
- name: Build Solution
run: dotnet build --configuration Release
- name: Test Solution
run: dotnet test --no-build --configuration Release
- name: Analyse Solution
if: github.ref == 'refs/heads/main'
uses: github/codeql-action/analyze@v2
pack:
runs-on: ubuntu-latest
needs: [build, linter]
if: github.event_name == 'push' || github.event_name == 'release'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: Pack for publish
if: github.event_name == 'release'
run: dotnet pack --output ./artifacts --configuration Release -p:PackageVersion=${{ github.event.release.tag_name }}
- name: Pack for push
if: github.event_name == 'push'
run: dotnet pack --output ./artifacts --configuration Release
- uses: actions/upload-artifact@v3
with:
name: artifacts
path: ./artifacts
publish:
runs-on: ubuntu-latest
needs: pack
if: github.event_name == 'release'
steps:
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- uses: actions/download-artifact@v3
with:
name: artifacts
path: ./artifacts
- name: Publish packages
run: dotnet nuget push ./artifacts/**/*.nupkg --source nuget.org --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate