In our development environment, we have set up a NuGet local server (BaGet). We have adopted the Gitflow idea. When a library is ready to be released on Baget, the developer should first increase the Tag on the master
branch (which needs to be approved first via a pull-request), then push the library to the Baget. We do this to keep the version of Git
and Nuget
in sync.
The process of keeping versions in sync (Git tag & NuGet version) is controlled manually by the developer and sometimes some team members forget to define the Git version tag and just push the library to Baget.
It would be a great help if the script
could check the Current Git Tag before pushing the library to the Baget server, and only push it if the Tag and Version are the same. This can prevent pushing a version without matching Tag on git.
We use this script for pushing to Baget:
#!/bin/bashclearDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"cd $DIRostype=`uname`KEY=$NUGET_KEYSOURCE=$NUGET_URLwhile :do clear echo "Input your package version: " read version Common="Dayan.Common/bin/Debug/Dayan.Common."$version".nupkg" dotnet nuget push $Common -s $SOURCE -k $KEY echo "press enter to continue ..." readdone
Can I somehow check use git commands in the bash to get the Tag of the last commit on the master branch of the project, and check it with the user input for version?