2022-06-05 18:44:51 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
cd $(dirname $0)/..
|
|
|
|
./scripts/setup.sh || exit 1
|
|
|
|
|
|
|
|
# Verify the input.
|
2022-09-06 04:14:29 +00:00
|
|
|
if [ "x$GITEA_TOKEN" = "x" ]
|
2022-06-05 18:44:51 +00:00
|
|
|
then
|
2022-09-06 04:14:29 +00:00
|
|
|
echo "the environment variable GITEA_TOKEN is not defined"
|
2022-06-05 18:44:51 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Clean up everything from the previous runs.
|
2022-09-06 04:14:29 +00:00
|
|
|
echo "$(basename $0): cleaning project"
|
2022-06-05 18:44:51 +00:00
|
|
|
dotnet clean
|
2023-01-18 21:49:51 +00:00
|
|
|
rm -f src/*/bin/Debug/*.nupkg
|
2022-06-05 18:44:51 +00:00
|
|
|
|
|
|
|
# Version the file based on the Git repository.
|
2022-09-06 04:14:29 +00:00
|
|
|
echo "$(basename $0): setting project version"
|
|
|
|
(cd src && dotnet dotnet-gitversion /updateprojectfiles)
|
2022-06-05 18:44:51 +00:00
|
|
|
SEMVER="v$(dotnet gitversion /output json | jq -r .SemVer)"
|
|
|
|
|
|
|
|
if [ "x$SEMVER" = "x" ]
|
|
|
|
then
|
2022-09-06 04:14:29 +00:00
|
|
|
echo "$(basename $0): cannot figure out the semantic version"
|
2022-06-05 18:44:51 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Build to pick up the new version.
|
2022-09-06 04:14:29 +00:00
|
|
|
echo "$(basename $0): building project $SEMVER"
|
|
|
|
dotnet build || exit 1
|
2022-06-05 18:44:51 +00:00
|
|
|
|
|
|
|
# Create and publish the NuGet packages.
|
2022-09-06 04:14:29 +00:00
|
|
|
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
|
2023-01-18 21:49:51 +00:00
|
|
|
dotnet nuget add source --name mfgames.com https://src.mfgames.com/api/packages/mfgames-cil/nuget/index.json || exit 1
|
|
|
|
dotnet nuget push --api-key $GITEA_TOKEN --skip-duplicate --source mfgames.com src/*/bin/Debug/*.nupkg || exit 1
|
2022-06-05 18:44:51 +00:00
|
|
|
|
|
|
|
# Tag and push, but only if we don't have a tag.
|
|
|
|
if ! git tag | grep $SEMVER >& /dev/null
|
|
|
|
then
|
2022-09-06 04:14:29 +00:00
|
|
|
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))
|
2022-06-05 18:44:51 +00:00
|
|
|
git tag $SEMVER
|
2022-09-06 04:14:29 +00:00
|
|
|
git push publish $SEMVER || exit 1
|
|
|
|
git remote remove publish
|
2022-06-05 18:44:51 +00:00
|
|
|
else
|
2022-09-06 04:14:29 +00:00
|
|
|
echo "$(basename $0): not tagging, already exists"
|
2022-06-05 18:44:51 +00:00
|
|
|
fi
|