Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: Build

on:
workflow_dispatch:
push:
branches: [ "dev"]
paths:
- src/**
- test/**
pull_request:
paths:
- src/**
- test/**

jobs:
build_and_test:

runs-on: ubuntu-latest
env:
PackageOutputDir: ".packages"
TESTRESULTS_DIRECTORY: '.test_results'

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.0
with:
versionSpec: '6.x'

- name: Determine Version
run: |
${GITVERSION_PATH}/dotnet-gitversion /output buildserver /output json

- name: Restore dependencies
run: dotnet restore

- name: Build
run: |
dotnet build --nologo --no-restore -p:AssemblyVersion=${GitVersion_AssemblySemVer} -p:FileVersion=${GitVersion_MajorMinorPatch} -p:Configuration=Release

- name: Test
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool --ignore-failed-sources
dotnet test --no-restore --verbosity normal --results-directory="${TESTRESULTS_DIRECTORY}" --logger:trx --collect:"XPlat Code Coverage${CI_DOTNET_TEST_COLLECTOR_OPT}" --nologo || (true && echo "ERROR test failure" >> errors)
reportgenerator -reports:${TESTRESULTS_DIRECTORY}/**/coverage.cobertura.xml '-reporttypes:TextSummary' -targetdir:${TESTRESULTS_DIRECTORY}/CoverageReports
printf 'TEST_TOTAL_COVERAGE: ' && grep 'Line coverage:' ${TESTRESULTS_DIRECTORY}/CoverageReports/Summary.txt | awk -F': ' '{print $2}'
if [ -e errors ] ; then cat errors ; exit 1 ; fi

- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1.3.0
with:
project-token: ${{ secrets.CODACY_API_KEY }}
coverage-reports: ${{ env.TESTRESULTS_DIRECTORY }}/**/*cobertura.xml

- name: Archive test report
uses: actions/upload-artifact@v4
with:
name: test-report
path: ${{ env.TESTRESULTS_DIRECTORY }}/**/*.*
73 changes: 73 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: Publish

on:
workflow_dispatch:
inputs:
prerelease:
default: true
type: boolean
required: true
push:
default: false
type: boolean
description: Push to nuget.org

push:
branches: [ "main" ]

jobs:
publish:

runs-on: ubuntu-latest
env:
PackageOutputDir: ".packages"
Prerelease: ${{ github.event.inputs.prerelease || 'false' }}
PushPackage: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event.inputs.push }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.0
with:
versionSpec: '6.x'

- name: Determine Version
run: |
${GITVERSION_PATH}/dotnet-gitversion /output buildserver /output json

- name: Pack
run: |
dotnet pack --nologo -o ${PackageOutputDir} \
-p:PackageVersion=${GitVersion_SemVer} \
-p:AssemblyVersion=${GitVersion_AssemblySemFileVer} \
-p:FileVersion=${GitVersion_MajorMinorPatch} \
-p:AssemblyVersion=${GitVersion_AssemblySemVer} \
-p:FileVersion=${GitVersion_MajorMinorPatch} \
-p:Configuration=Release

- name: Nuget Push
if: env.PushPackage == 'true'
working-directory: ${{ env.PackageOutputDir }}
run: dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}}

- name: Create Release
uses: ncipollo/release-action@v1
with:
name: v${{ env.GitVersion_SemVer }}
tag: v${{ env.GitVersion_SemVer }}
artifacts: ${{ env.PackageOutputDir }}/*.nupkg
generateReleaseNotes: true
commit: ${{ env.GitVersion_Sha}}
prerelease: ${{ env.Prerelease }}

6 changes: 3 additions & 3 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mode: ContinuousDelivery
branches:
main:
tag: ''
label: ''
increment: Patch
is-mainline: true
is-main-branch: true
develop:
tag: rc
label: rc
ignore:
sha: []
merge-message-formats: {}
Expand Down
3 changes: 1 addition & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

[![NuGet Version](https://img.shields.io/nuget/vpre/ApiCodeGenerator.MSBuild?style=flat-square)](https://www.nuget.org/packages/ApiCodeGenerator.MSBuild)
[![GitHub License](https://img.shields.io/github/license/MobileTeleSystems/ApiCodeGenerator?style=flat-square)](https://github.com/MobileTeleSystems/ApiCodeGenerator/blob/dev/LICENSE)
![Code Coverage](https://img.shields.io/badge/84.90%25-z?style=flat-square&label=coverage) <!--
Before setting up the workflow, the coverage percentage is taken from the IDE -->
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/bcf93c4065c3442b92e5e95671b8cfcf)](https://app.codacy.com/gh/MobileTeleSystems/ApiCodeGenerator/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)

# How to install

Expand Down