mfgames-cil/Justfile

152 lines
4 KiB
Makefile
Raw Normal View History

2023-07-10 04:11:38 +00:00
set dotenv-load := true
2023-07-22 23:46:41 +00:00
export DOTNET_CLI_TELEMETRY_OPTOUT := "1"
@_default:
2023-07-22 18:36:30 +00:00
just --list
2023-07-10 04:27:05 +00:00
# Cleans out the packages.
clean:
2023-07-13 01:31:25 +00:00
dotnet clean -v:m
2023-07-10 04:27:05 +00:00
# Formats everything in the package.
format:
treefmt
just --fmt --unstable
# Builds all of the components of this repository.
build: format
dotnet build
# Runs all the known tests in the repository.
2023-07-22 20:28:59 +00:00
test: test-tool test-packages
test-tool:
2023-07-22 21:54:38 +00:00
dotnet build examples/SampleTool/SampleTool.csproj
dotnet run --no-build --project examples/SampleTool/SampleTool.csproj -- table
2023-07-22 21:39:24 +00:00
dotnet run --no-build --project examples/SampleTool/SampleTool.csproj -- log
2023-07-22 20:28:59 +00:00
2023-08-03 12:43:51 +00:00
test-packages: build
2023-07-13 01:31:25 +00:00
#!/usr/bin/env bash
2023-07-22 21:39:24 +00:00
set -euxo pipefail
dotnet test \
2023-08-03 12:43:51 +00:00
--no-build \
2023-07-13 01:31:25 +00:00
--test-adapter-path:. \
--logger:"junit;LogFilePath=../artifacts/{assembly}-test-result.xml;MethodFormat=Default;FailureBodyFormat=Verbose" \
--collect:"XPlat Code Coverage" \
2023-08-03 12:43:51 +00:00
/p:CollectCoverage=true \
2023-08-03 12:53:41 +00:00
-v:q --nologo
2023-07-13 01:31:25 +00:00
2023-09-02 17:02:56 +00:00
coverage-packages: test-packages
#!/usr/bin/env bash
set -euxo pipefail
2023-07-13 01:31:25 +00:00
dotnet tool run reportgenerator \
-reports:tests/*/TestResults/*/coverage.cobertura.xml \
-targetdir:./coverage \
2023-08-03 12:53:41 +00:00
"-reporttypes:Cobertura;TextSummary" || true
2023-07-13 01:31:25 +00:00
2023-08-03 12:53:41 +00:00
if [ -f coverage/Summary.txt ]
then
grep "Line coverage" coverage/Summary.txt || true
fi
# Restores all the tools and NuGet packages.
restore: restore-tools restore-packages
# Restores all the dotnet tools used.
restore-tools:
dotnet tool restore
# Restores all the NuGet packages.
restore-packages:
dotnet restore
2023-07-10 04:27:05 +00:00
# Performs a release on all the packages.
2024-03-08 06:25:18 +00:00
release: release-setup release-nuget release-tag
2023-07-22 23:46:41 +00:00
# Makes sure all the release environment variables are set up.
2023-07-23 17:03:43 +00:00
release-setup: restore-tools restore-packages
2023-07-13 01:31:25 +00:00
#!/usr/bin/env bash
2023-07-22 23:46:41 +00:00
set -euxo pipefail
2023-07-13 01:31:25 +00:00
# Verify that all the variables are set.
2024-03-08 05:02:07 +00:00
if [ "x$MFGAMES_GITEA_TOKEN" = "x" ]; then
echo "the environment variable MFGAMES_GITEA_TOKEN is not defined"
2023-07-13 01:31:25 +00:00
exit 1
fi
2024-03-10 06:00:36 +00:00
# Sets the version for all the packages based on conventional commits
2024-03-10 18:22:44 +00:00
2024-03-10 06:00:36 +00:00
# and semantic releases.
release-version:
#!/usr/bin/env bash
set -euo pipefail
cd src
for pkg in MfGames*
do
ver=$(mfgames-conventional-commit version --package $pkg)
dotnet setversion $ver $pkg/$pkg.csproj
done
2023-07-22 23:46:41 +00:00
# Creates and pushes the NuGet packages.
2024-03-10 06:00:36 +00:00
release-pack: release-setup release-version
2023-07-22 23:46:41 +00:00
# Rebuild the package in release mode.
dotnet clean --configuration Release
dotnet build --configuration Release
2023-07-22 23:46:41 +00:00
dotnet pack \
-p:IncludeSymbols=true \
-p:SymbolPackageFormat=snupkg \
--configuration Release
2024-03-08 06:25:18 +00:00
fd nupkg --no-ignore
2023-07-23 17:28:42 +00:00
2024-03-08 06:25:18 +00:00
release-nuget: release-pack
2023-07-13 01:31:25 +00:00
# Publish the packages.
dotnet nuget remove source publish >&/dev/null || true
2023-07-22 23:46:41 +00:00
dotnet nuget add source \
--name publish \
--username dmoonfire \
2024-03-08 05:02:07 +00:00
--password $MFGAMES_GITEA_TOKEN \
2023-07-22 23:46:41 +00:00
https://src.mfgames.com/api/packages/mfgames-cil/nuget/index.json \
--store-password-in-clear-text
dotnet nuget push --skip-duplicate --source publish src/*/bin/Release/*.nupkg
dotnet nuget push --skip-duplicate --source publish src/*/bin/Release/*.snupkg
dotnet nuget remove source publish || true
2023-07-22 23:46:41 +00:00
# Tags all the libraries for the release.
2023-07-23 00:23:05 +00:00
release-tag: release-setup
2023-07-22 23:46:41 +00:00
#!/usr/bin/env bash
2024-03-10 06:00:36 +00:00
set -euo pipefail
2023-07-13 01:31:25 +00:00
git remote remove publish || true
2024-03-08 05:02:07 +00:00
git remote add publish https://dmoonfire:$MFGAMES_GITEA_TOKEN@src.mfgames.com/mfgames-cil/$(basename $(git config --get remote.origin.url))
2023-07-13 01:31:25 +00:00
2024-03-10 06:00:36 +00:00
cd src
for pkg in MfGames*
2023-07-13 01:31:25 +00:00
do
# Move into the proper directory.
2024-03-10 06:00:36 +00:00
dir=$pkg
2023-07-13 01:31:25 +00:00
pushd $dir
2024-03-08 05:37:21 +00:00
# Check the version and see if we have tagged it already.
2024-03-10 06:00:36 +00:00
ver=$(mfgames-conventional-commit version --package $pkg)
tag="$pkg-$ver"
2023-07-24 01:19:33 +00:00
if git tag | grep $tag > /dev/null
then
echo "already tagged $tag"
else
echo "tagging $pkg with $tag"
2024-03-08 05:37:21 +00:00
git tag $tag || true
git push publish $tag || true
fi
2023-07-13 01:31:25 +00:00
# Move back so we can finish.
popd
done