76 lines
2.3 KiB
YAML
76 lines
2.3 KiB
YAML
image: mcr.microsoft.com/dotnet/sdk:9.0
|
|
|
|
stages:
|
|
- build
|
|
- test
|
|
- publish
|
|
- publish-help
|
|
|
|
build:
|
|
stage: build
|
|
only:
|
|
- pushes
|
|
script:
|
|
- dotnet restore
|
|
- dotnet build --configuration Release --no-restore
|
|
artifacts:
|
|
paths:
|
|
- "**/bin/Release"
|
|
expire_in: 10 minutes
|
|
|
|
test:
|
|
stage: test
|
|
only:
|
|
- pushes
|
|
script:
|
|
- dotnet test HopFrame.sln --logger "trx;LogFilePrefix=testresults" --collect:"XPlat Code Coverage" --results-directory TestResults
|
|
- dotnet tool install --global trx2junit
|
|
- dotnet tool install --global dotnet-reportgenerator-globaltool
|
|
- export PATH="$PATH:/root/.dotnet/tools"
|
|
- for file in TestResults/*.trx; do trx2junit "$file"; done
|
|
- reportgenerator -reports:"TestResults/**/coverage.cobertura.xml" -targetdir:"coveragereport" -reporttypes:"Cobertura;HtmlInline"
|
|
- echo total_coverage=$(grep -o 'line-rate="[0-9.]*"' coveragereport/Cobertura.xml | head -n1 | sed -E 's/line-rate="([0-9.]+)"/\1/' | awk '{printf "%.2f", $1 * 100}')
|
|
- tar -cvf coveragereport.tar coveragereport/
|
|
artifacts:
|
|
when: always
|
|
expire_in: 1 week
|
|
paths:
|
|
- TestResults/*.xml
|
|
- TestResults/**/*.coverage.cobertura.xml
|
|
- coveragereport.tar
|
|
reports:
|
|
junit:
|
|
- TestResults/*.xml
|
|
coverage_report:
|
|
coverage_format: cobertura
|
|
path: coveragereport/Cobertura.xml
|
|
coverage: '/total_coverage=(\d+(\.\d+)?)/'
|
|
|
|
publish:
|
|
stage: publish
|
|
script:
|
|
- export VERSION=$(echo $CI_COMMIT_TAG | sed 's/^v//')
|
|
- dotnet pack -c Release -o . /p:Version=$VERSION
|
|
- for nupkg in *.nupkg; do dotnet nuget push $nupkg -k ${NUGET_API_KEY} -s https://api.nuget.org/v3/index.json; done
|
|
only:
|
|
- tags
|
|
dependencies:
|
|
- build
|
|
- test
|
|
|
|
publish-help:
|
|
stage: publish-help
|
|
tags:
|
|
- docker
|
|
script:
|
|
- export VERSION=$(echo $CI_COMMIT_TAG | sed 's/^v//')
|
|
- cd docs
|
|
- docker login -u leon.hoppe -p ${CI_REGISTRY_PASSWORD} registry.leon-hoppe.de
|
|
- docker build -t registry.leon-hoppe.de/leon.hoppe/hopframe:$VERSION -t registry.leon-hoppe.de/leon.hoppe/hopframe:latest .
|
|
- docker push registry.leon-hoppe.de/leon.hoppe/hopframe:$VERSION
|
|
- docker push registry.leon-hoppe.de/leon.hoppe/hopframe:latest
|
|
only:
|
|
- tags
|
|
dependencies:
|
|
- publish
|