Skip to content

chore(pipeline): fix nuget path #239

chore(pipeline): fix nuget path

chore(pipeline): fix nuget path #239

################ CI and CD pipeline ################
# On push, runs the CI pipeline: Clean, Restore, Build, Code Quality Analysis, Test and Coverage tasks, in that order.
# On versioning (new tag), runs the CD pipeline: CI pipeline, Package and Publish tasks, in that order.
# Docs:
# - https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# - https://docs.microsoft.com/en-us/dotnet/core/tools/?tabs=netcore
# - https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/MSBuildIntegration.md
# - https://danielpalme.github.io/ReportGenerator/usage.html
name: CI / CD pipeline
on:
push:
branches: [ master ]
paths-ignore:
- 'README.md'
pull_request:
branches: [ master ]
types: [opened, synchronize, reopened]
paths-ignore:
- 'README.md'
create:
branches: [ master ]
jobs:
build:
runs-on: windows-latest
################ SETUP .NET STEPS ################
steps:
- name: Checkout the repo
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup .NET Core
uses: actions/[email protected]
with:
dotnet-version: 7.0.400
source-url: https://nuget.pkg.github.com/maiconheck/index.json
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
DOTNET_CLI_TELEMETRY_OPTOUT: 1
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Install the .NET tools
run: dotnet tool restore
################## CI STEPS ##################
# Cannot reuse Sonar build step, because it the "begin" step will modify your build like this:
# - the active CodeAnalysisRuleSet will be updated to match the SonarQube quality profile
# - WarningsAsErrors will be turned off
# Docs: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/
- name: CLEAN - Cleans the output
run: dotnet clean "./src/Krafted/Krafted.sln"
- name: RESTORE - Install the dependencies
run: dotnet restore "./src/Krafted/Krafted.sln"
- name: ROSLYN CODE QUALITY - Run code quality analysis with other Roslyn Analyzers
run: dotnet build "./src/Krafted/Krafted.sln" --configuration Release --no-restore -warnaserror
- name: TEST - Executes unit and integration tests
run: |
dotnet test "./src/Krafted/Krafted.sln" --no-restore `
/p:CollectCoverage=true `
/p:CoverletOutput="../../coverage-results/" `
/p:MergeWith="../../coverage-results/coverage.json" `
/p:ExcludeByAttribute="GeneratedCodeAttribute%2cCompilerGeneratedAttribute" `
/p:SkipAutoProps=true `
/p:CoverletOutputFormat="opencover%2cjson" `
-m:1 `
/p:Threshold=93 `
/p:ThresholdStat=average
################ SETUP SONAR STEPS ################
- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: SONAR CODE QUALITY - Build, Run unit and integration tests, and code quality analysis with Sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# DOTNET_ROLL_FORWARD: Major
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"maiconheck_krafted" /o:"maiconheck-github" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="./src/coverage-results/coverage.opencover.xml"
dotnet clean "./src/Krafted/Krafted.sln"
dotnet restore "./src/Krafted/Krafted.sln"
dotnet build "./src/Krafted/Krafted.sln" --configuration Release --no-restore
dotnet test "./src/Krafted/Krafted.sln" --no-restore /p:CollectCoverage=true /p:CoverletOutput="../../coverage-results/" /p:MergeWith="../../coverage-results/coverage.json" /p:ExcludeByAttribute="GeneratedCodeAttribute%2cCompilerGeneratedAttribute" /p:CoverletOutputFormat="opencover%2cjson" -m:1 /p:Threshold=93 /p:ThresholdStat=average
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
################## CD STEPS ##################
- name: PACKAGE - Generates the nuget packages
if: startsWith(github.ref, 'refs/tags/')
run: dotnet pack "./src/Krafted/Krafted.sln" --property:PackageOutputPath="../../../artifacts" --include-symbols --include-source
- name: PUBLISH - Pushes the packages to the server and publishes them
if: startsWith(github.ref, 'refs/tags/')
run: dotnet nuget push "D:\a\krafted\krafted\artifacts\*.nupkg" --skip-duplicate -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
NUGET_AUTH_TOKEN: ${{secrets.NUGET_API_KEY}}
################## DOC STEPS ##################
- name: Setup DocFX
if: github.event_name == 'push'
uses: crazy-max/ghaction-chocolatey@v1
with:
args: install docfx
- name: DocFX Build
if: github.event_name == 'push'
working-directory: docfx_project
run: docfx docfx.json
continue-on-error: false
- name: DocFX Publish
if: github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docfx_project/_site
force_orphan: true