build: adding tagging for the release process

This commit is contained in:
D. Moonfire 2022-04-02 23:44:57 -05:00
parent fe53cfb17e
commit d4d7ff4cba
2 changed files with 21 additions and 2 deletions

View file

@ -17,6 +17,7 @@
pkgs.convco pkgs.convco
pkgs.nodePackages.prettier pkgs.nodePackages.prettier
pkgs.nixfmt pkgs.nixfmt
pkgs.jq
]; ];
}; };
}); });

View file

@ -6,20 +6,28 @@ cd $(dirname $0)/..
# Verify the input. # Verify the input.
if [ "x$NUGET_TOKEN" = "x" ] if [ "x$NUGET_TOKEN" = "x" ]
then then
echo "The environment variable NUGET_TOKEN is not defined" echo "the environment variable NUGET_TOKEN is not defined"
exit 1 exit 1
fi fi
if [ "x$NUGET_PUSH_URL" = "x" ] if [ "x$NUGET_PUSH_URL" = "x" ]
then then
echo "The environment variable NUGET_PUSH_URL is not defined" echo "the environment variable NUGET_PUSH_URL is not defined"
exit 1 exit 1
fi fi
# Clean up everything from the previous runs. # Clean up everything from the previous runs.
dotnet clean dotnet clean
# Version the file based on the Git repository. # Version the file based on the Git repository.
(cd src && dotnet dotnet-gitversion /updateprojectfiles) (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"
exit 1
fi
# Build to pick up the new version. # Build to pick up the new version.
dotnet build dotnet build
@ -27,3 +35,13 @@ dotnet build
# Create and publish the NuGet packages. # Create and publish the NuGet packages.
dotnet pack --include-symbols --include-source dotnet pack --include-symbols --include-source
dotnet nuget push src/*/bin/Debug/*.nupkg --api-key $NUGET_TOKEN --source $NUGET_PUSH_URL dotnet nuget push src/*/bin/Debug/*.nupkg --api-key $NUGET_TOKEN --source $NUGET_PUSH_URL
# Tag and push, but only if we don't have a tag.
if ! git tag | grep $SEMVER >& /dev/null
then
echo "tagging and pushing"
git tag $SEMVER
git push origin $SEMVER
else
echo "not tagging, already exists"
fi