This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-toolbuilder-cil/scripts/release.sh

52 lines
1.7 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env sh
2022-04-02 21:42:32 +00:00
cd $(dirname $0)/..
2022-04-02 21:42:32 +00:00
./scripts/setup.sh || exit 1
2022-04-02 21:42:32 +00:00
# Verify the input.
2022-09-06 03:06:02 +00:00
if [ "x$GITEA_TOKEN" = "x" ]
2022-04-02 21:42:32 +00:00
then
2022-09-06 03:06:02 +00:00
echo "the environment variable GITEA_TOKEN is not defined"
2022-04-02 21:42:32 +00:00
exit 1
fi
# Clean up everything from the previous runs.
2022-09-06 03:06:02 +00:00
echo "$(basename $0): cleaning project"
dotnet clean
2022-04-02 21:42:32 +00:00
# Version the file based on the Git repository.
2022-09-06 03:06:02 +00:00
echo "$(basename $0): setting project version"
2022-04-02 21:42:32 +00:00
(cd src && dotnet dotnet-gitversion /updateprojectfiles)
SEMVER="v$(dotnet gitversion /output json | jq -r .SemVer)"
if [ "x$SEMVER" = "x" ]
then
2022-09-06 03:06:02 +00:00
echo "$(basename $0): cannot figure out the semantic version"
exit 1
fi
2022-04-02 21:42:32 +00:00
# Build to pick up the new version.
2022-09-06 03:06:02 +00:00
echo "$(basename $0): building project $SEMVER"
dotnet build || exit 1
2022-04-02 21:42:32 +00:00
# Create and publish the NuGet packages.
2022-09-06 03:06:02 +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
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
2022-09-06 03:06:02 +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))
git tag $SEMVER
2022-09-06 03:06:02 +00:00
git push publish $SEMVER || exit 1
git remote remove publish
else
2022-09-06 03:06:02 +00:00
echo "$(basename $0): not tagging, already exists"
fi