build: adding versioning and updating

This commit is contained in:
Dylan R. E. Moonfire 2021-01-21 18:02:19 -06:00
parent 28898dbaff
commit 1d6d7d4ec3
7 changed files with 5264 additions and 4 deletions

6
.gitignore vendored
View file

@ -2,8 +2,7 @@ launchSettings.json
*~ *~
*.user *.user
Directory.Build.props
NaNoGenMo.*
obj/ obj/
[Bb]in/ [Bb]in/
@ -11,5 +10,4 @@ obj/
.vscode/ .vscode/
.idea/ .idea/
_ReSharper.Caches/ _ReSharper.Caches/
node_modules/
.author-intrusion

75
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,75 @@
stages:
- test
- tag
- deploy
# The test stage runs on every build and every branch.
test:
image: mcr.microsoft.com/dotnet/sdk:5.0
stage: test
script:
# Make sure the commits follow our rules.
- yarn install --frozen-lockfile
- if [ $CI_BUILD_BEFORE_SHA == "0000000000000000000000000000000000000000" ]; then npx commitlint --to=HEAD; else npx commitlint --from=$CI_BUILD_BEFORE_SHA; fi
# Build and test the project.
- dotnet restore
- dotnet build
- 'dotnet test --test-adapter-path:. --logger:"junit;LogFilePath=../artifacts/{assembly}-test-result.xml;MethodFormat=Default;FailureBodyFormat=Verbose" --collect:"XPlat Code Coverage"'
# Summarize the output for Gitlab CI reporting.
- dotnet new tool-manifest
- dotnet tool install dotnet-reportgenerator-globaltool
- dotnet tool run reportgenerator -reports:src/*/TestResults/*/coverage.cobertura.xml -targetdir:./coverage "-reporttypes:Cobertura;TextSummary"
- grep "Line coverage" coverage/Summary.txt
rules:
- if: '$CI_COMMIT_TITLE =~ /^(docs|chore\(release\))/'
when: never
- if: '$CI_COMMIT_TAG'
when: never
- when: on_success
artifacts:
when: always
paths:
- ./**/*test-result.xml
- ./coverage/Cobertura.xml
- ./coverage/Summary.*
reports:
junit:
- ./**/*test-result.xml
cobertura:
- ./coverage/Cobertura.xml
# Tagging only runs on the master branches and after testing.
tag:
image: mcr.microsoft.com/dotnet/sdk:5.0
stage: tag
needs: [test]
script:
- yarn install --frozen-lockfile
- npx semantic-release
rules:
- if: '$CI_COMMIT_TITLE =~ /^(docs|chore\(release\))/'
when: never
- if: '$CI_COMMIT_TAG'
when: never
- if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
when: never
- when: on_success
# Publish the packages.
deploy:
image: mcr.microsoft.com/dotnet/sdk:5.0
needs: []
stage: deploy
script:
- dotnet restore
- dotnet build
- dotnet pack -c Release
- dotnet nuget add source "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text
- dotnet nuget push "bin/*.nupkg" --source gitlab
rules:
- if: '$FORCE_DEPLOY'
- if: '$CI_COMMIT_TITLE =~ /^chore\(release\)/ && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never

View file

@ -1 +1,2 @@
dotnet-core 5.0.100 dotnet-core 5.0.100
yarn 1.22.10

42
package.json Normal file
View file

@ -0,0 +1,42 @@
{
"name": "mfgames-locking-cil",
"version": "1.0.0",
"private": true,
"scripts": {
"commitlint": "commitlint "
},
"release": {
"branch": "master",
"message": "chore(release): v${nextRelease.version}\n\n${nextRelease.notes}",
"verifyConditions": [
"@semantic-release/git"
],
"analyzeCommits": [
"@semantic-release/commit-analyzer"
],
"prepare": [
"@semantic-release/npm",
"@semantic-release/git"
],
"publish": [],
"success": [],
"fail": []
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@semantic-release/git": "^9.0.0",
"husky": "^4.3.6",
"semantic-release": "^17.3.0"
}
}

21
scripts/set-build-version.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
# This sets the build version using a `Directory.Build.props` at the top-level
# of the project.
# Move into the root directory.
cd $(dirname $0)
cd ..
# Get the version from `package.json`.
VERSION=$(grep '"version":' package.json | cut -f 4 -d '"')
cat > src/Directory.Build.props << EOL
<Project>
<PropertyGroup>
<Version>$VERSION</Version>
</PropertyGroup>
</Project>
EOL

View file

@ -7,6 +7,11 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CompareNETObjects" Version="4.70.0" /> <PackageReference Include="CompareNETObjects" Version="4.70.0" />
<PackageReference Include="coverlet.collector" Version="3.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="JunitXml.TestLogger" Version="2.1.81" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="Roslynator.Analyzers" Version="3.0.0"> <PackageReference Include="Roslynator.Analyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>

5118
yarn.lock Normal file

File diff suppressed because it is too large Load diff