fix: integrating common project layout
This commit is contained in:
parent
11fd5fd0ff
commit
9a713fae0e
8 changed files with 61 additions and 42 deletions
13
NuGet.Config
13
NuGet.Config
|
@ -1,7 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
<add key="mfgames" value="https://www.myget.org/F/mfgames/api/v3/index.json" protocolVersion="3" />
|
||||
<add key="mfgames.com" value="https://src.mfgames.com/api/packages/mfgames-cil/nuget/index.json" protocolVersion="3" />
|
||||
</packageSources>
|
||||
<packageSourceMapping>
|
||||
<packageSource key="nuget.org">
|
||||
<package pattern="*" />
|
||||
</packageSource>
|
||||
<packageSource key="mfgames.com">
|
||||
<package pattern="MfGames.*" />
|
||||
</packageSource>
|
||||
</packageSourceMapping>
|
||||
</configuration>
|
||||
|
|
12
flake.lock
12
flake.lock
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1648297722,
|
||||
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -17,11 +17,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1648390671,
|
||||
"narHash": "sha256-u69opCeHUx3CsdIerD0wVSR+DjfDQjnztObqfk9Trqc=",
|
||||
"lastModified": 1662019588,
|
||||
"narHash": "sha256-oPEjHKGGVbBXqwwL+UjsveJzghWiWV0n9ogo1X6l4cw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ce8cbe3c01fd8ee2de526ccd84bbf9b82397a510",
|
||||
"rev": "2da64a81275b68fdad38af669afeda43d401e94b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
18
lefthook.yml
18
lefthook.yml
|
@ -1,9 +1,3 @@
|
|||
pre-push:
|
||||
parallel: true
|
||||
commands:
|
||||
commit-check:
|
||||
run: convco check -n 30
|
||||
|
||||
pre-commit:
|
||||
parallel: true
|
||||
commands:
|
||||
|
@ -14,3 +8,15 @@ pre-commit:
|
|||
run: prettier . --write --loglevel warn
|
||||
nixfmt:
|
||||
run: nixfmt flake.nix
|
||||
|
||||
commit-msg:
|
||||
commands:
|
||||
commit-check:
|
||||
run: convco check -n 1
|
||||
|
||||
skip_output:
|
||||
- meta # Skips lefthook version printing
|
||||
- summary # Skips summary block (successful and failed steps) printing
|
||||
- success # Skips successful steps printing
|
||||
- failure # Skips failed steps printing
|
||||
- execution # Skips printing successfully executed commands and their output (but still prints failed executions)
|
||||
|
|
|
@ -3,4 +3,5 @@
|
|||
cd $(dirname $0)/..
|
||||
./scripts/setup.sh || exit 1
|
||||
|
||||
echo "$(basename $0): building project"
|
||||
dotnet build
|
||||
|
|
|
@ -1,14 +1,4 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# Normalize our environment.
|
||||
cd $(dirname $0)/..
|
||||
./scripts/setup.sh || exit 1
|
||||
|
||||
# Format the .NET code
|
||||
dotnet format || exit 1
|
||||
|
||||
# Format using Prettier.
|
||||
prettier . --write --loglevel warn
|
||||
|
||||
# Format the Flake.
|
||||
nixfmt flake.nix
|
||||
lefthook run pre-commit
|
||||
|
|
|
@ -4,44 +4,48 @@ cd $(dirname $0)/..
|
|||
./scripts/setup.sh || exit 1
|
||||
|
||||
# Verify the input.
|
||||
if [ "x$NUGET_TOKEN" = "x" ]
|
||||
if [ "x$GITEA_TOKEN" = "x" ]
|
||||
then
|
||||
echo "the environment variable NUGET_TOKEN is not defined"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "x$NUGET_PUSH_URL" = "x" ]
|
||||
then
|
||||
echo "the environment variable NUGET_PUSH_URL is not defined"
|
||||
echo "the environment variable GITEA_TOKEN is not defined"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clean up everything from the previous runs.
|
||||
echo "$(basename $0): cleaning project"
|
||||
dotnet clean
|
||||
|
||||
# Version the file based on the Git repository.
|
||||
echo "$(basename $0): setting project version"
|
||||
(cd src && dotnet dotnet-gitversion /updateprojectfiles)
|
||||
SEMVER="v$(dotnet gitversion /output json | jq -r .SemVer)"
|
||||
|
||||
if [ "x$SEMVER" = "x" ]
|
||||
then
|
||||
echo "cannot figure out the semantic version"
|
||||
echo "$(basename $0): cannot figure out the semantic version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build to pick up the new version.
|
||||
dotnet build
|
||||
echo "$(basename $0): building project $SEMVER"
|
||||
dotnet build || exit 1
|
||||
|
||||
# Create and publish the NuGet packages.
|
||||
dotnet pack --include-symbols --include-source
|
||||
dotnet nuget push src/*/bin/Debug/*.nupkg --api-key $NUGET_TOKEN --source $NUGET_PUSH_URL
|
||||
echo "$(basename $0): creating NuGet packages"
|
||||
dotnet pack -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg || exit 1
|
||||
|
||||
echo "$(basename $0): publishing NuGet package"
|
||||
dotnet nuget remove source mfgames.com >& /dev/null
|
||||
dotnet nuget add source --name mfgames.com --username dmoonfire --password $GITEA_TOKEN https://src.mfgames.com/api/packages/mfgames-cil/nuget/index.json --store-password-in-clear-text || exit 1
|
||||
dotnet nuget push --skip-duplicate --source mfgames.com src/*/bin/Debug/*.nupkg || exit 1
|
||||
|
||||
# Tag and push, but only if we don't have a tag.
|
||||
if ! git tag | grep $SEMVER >& /dev/null
|
||||
then
|
||||
echo "tagging and pushing"
|
||||
echo "$(basename $0): tagging and pushing"
|
||||
git remote add publish https://dmoonfire:$GITEA_TOKEN@src.mfgames.com/mfgames-cil/$(basename $(git config --get remote.origin.url))
|
||||
git tag $SEMVER
|
||||
git push origin $SEMVER
|
||||
git push publish $SEMVER || exit 1
|
||||
git remote remove publish
|
||||
else
|
||||
echo "not tagging, already exists"
|
||||
echo "$(basename $0): not tagging, already exists"
|
||||
fi
|
||||
|
|
|
@ -14,9 +14,14 @@ do
|
|||
done
|
||||
|
||||
# Make sure we have lefthook is installed.
|
||||
if [ ! -f .git/hooks/pre-commit ]
|
||||
then
|
||||
echo "$(basename $0): installing lefthook"
|
||||
lefthook install
|
||||
fi
|
||||
|
||||
# Make sure our tools are installed.
|
||||
echo "$(basename $0): install .NET tools"
|
||||
dotnet tool restore
|
||||
|
||||
# Everything is good.
|
||||
|
|
4
scripts/update-template.sh
Executable file
4
scripts/update-template.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
cd $(dirname $0)/..
|
||||
git pull template main --no-rebase
|
Reference in a new issue