Skip to content

Commit

Permalink
CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
Elanis committed Dec 23, 2024
1 parent 81cec96 commit 77f69bf
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: .NET

on:
push:
branches: [ "main" ]
tags: [ "*" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

env:
SONAR_KEY: lumen-module-sdk
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
CSPROJ: Lumen.Modules.Sdk/Lumen.Modules.Sdk.csproj
NUGET_SERVER_ADRESS: https://api.nuget.org/v3/index.json
NUGET_SERVER_KEY: ${{ secrets.NUGET_ORG_KEY }}

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'

- name: Setup sonarscanner
run: |
dotnet tool install --global dotnet-sonarscanner
- name: Start sonarscanner
run: dotnet sonarscanner begin /k:"${{ env.SONAR_KEY }}" /d:sonar.host.url="${{ env.SONAR_HOST_URL }}" /d:sonar.token="${{ env.SONAR_TOKEN }}" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.coverage.exclusions="**Test*.cs" /d:sonar.branch.name="${{github.ref_name}}"

- name: Set Version in csproj
if: startsWith(github.event.ref, 'refs/tags/')
run: sed -i 's/>1.0.0</>${{github.ref_name}}</g' ${{ env.CSPROJ }}

- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: |
dotnet tool install --global dotnet-coverage
dotnet-coverage collect 'dotnet test --no-build --verbosity normal' -f xml -o 'coverage.xml'
- name: End sonarscanner
run: dotnet sonarscanner end /d:sonar.token="${{ env.SONAR_TOKEN }}"

- name: Pack
run: dotnet pack ${{ env.CSPROJ }} -c Release -o out
- name: Push
if: startsWith(github.event.ref, 'refs/tags/')
run: dotnet nuget push -s ${{ env.NUGET_SERVER_ADRESS }} -k ${{ env.NUGET_SERVER_KEY }} $(ls out/*.nupkg | head -1)
10 changes: 10 additions & 0 deletions Lumen.Modules.Sdk/Lumen.Modules.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Axel "Elanis" Soupé</Authors>
<Description>LUMEN Personal Assistant Modules base</Description>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/L-U-M-E-N/Lumen.Modules.Sdk</PackageProjectUrl>
<RepositoryUrl>https://github.com/L-U-M-E-N/Lumen.Modules.Sdk</RepositoryUrl>
<RepositoryType>Github</RepositoryType>
<PackageReleaseNotes></PackageReleaseNotes>
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 77f69bf

Please sign in to comment.