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.

52 lines
1.7 KiB
Executable File

#!/usr/bin/env sh
cd $(dirname $0)/..
./scripts/ || exit 1
# Verify the input.
if [ "x$GITEA_TOKEN" = "x" ]
echo "the environment variable GITEA_TOKEN is not defined"
exit 1
# 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" ]
echo "$(basename $0): cannot figure out the semantic version"
exit 1
# Build to pick up the new version.
echo "$(basename $0): building project $SEMVER"
dotnet build || exit 1
# Create and publish the NuGet packages.
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 >& /dev/null
dotnet nuget add source --name --username dmoonfire --password $GITEA_TOKEN --store-password-in-clear-text || exit 1
dotnet nuget push --skip-duplicate --source 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
echo "$(basename $0): tagging and pushing"
git remote add publish https://dmoonfire:$$(basename $(git config --get remote.origin.url))
git tag $SEMVER
git push publish $SEMVER || exit 1
git remote remove publish
echo "$(basename $0): not tagging, already exists"