fix version release

This commit is contained in:
Trevor Batley 2023-11-17 14:49:55 +11:00
parent eaf957da50
commit ce14ed07fc

View File

@ -46,6 +46,8 @@ done < "$inifilename"
DEBUG=
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
REPO_NAME=$1
ORGGITEA=$2
GITEAUser=${remote_USER}
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
GITEAHOST=${remote_GITEAHOST}
@ -96,7 +98,7 @@ else
WORKDIR=${smegit_WORKDIR}
fi
if [ $DEBUG ] ; then echo "WORKDIR=$WORKDIR" ; fi
RemoteRepoURL="$GITEAHOST/$2/$1"
RemoteRepoURL="$GITEAHOST/$ORGGITEA/$REPO_NAME"
# Make sure credentials taken from store
# The first time you pull or push it will ask for credentials and then save them in a file.
@ -108,27 +110,26 @@ mkdir -p $GITFiles
cd $GITFiles
# Delete the local first
if [ -d "$1" ] ; then
if [ -d "$REPO_NAME" ] ; then
if [ $DEBUG ] ; then echo "************Deleting local GIT files" ; fi
rm -Rf $GITFiles/$1
rm -Rf $GITFiles/$REPO_NAME
fi
# See if it exists on the Gitea host
REPO_NAME=$1
if [ $DEBUG ] ; then echo "check that $GITEAHOST/$ORGGITEA/$REPO_NAME exists" ; fi
RESPONSE=$(curl $checkSSL $SILENT4CURL -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORGGITEA/$REPO_NAME")
if [ "$RESPONSE" == "200" ]; then
if [ $DEBUG ] ; then echo "************Repository for $1 exists, cloning!" ; fi
if [ $DEBUG ] ; then echo "************Repository for $REPO_NAME exists, cloning!" ; fi
# If so, clone it (just want the README.md)
if [ $DEBUG ] ; then echo "git clone $GITEAHOST/$ORGGITEA/$1.git" ; fi
if [ $DEBUG ] ; then echo "git clone $GITEAHOST/$ORGGITEA/$REPO_NAME.git" ; fi
cd $GITFiles
git clone "$GITEAHOST/$ORGGITEA/$1.git"
git clone "$GITEAHOST/$ORGGITEA/$REPO_NAME.git"
else
echo "************Repository for $2/$1 does not exist. Aborting"
echo "************Repository for $ORGGITEA/$REPO_NAME does not exist. Aborting $RESPONSE"
exit 1
fi
cd $GITFiles/$1
cd $GITFiles/$REPO_NAME
# read the existing tags
OLDTAGS=$(git tag --list)
# delete old tag/s
@ -136,12 +137,14 @@ for tag in $OLDTAGS ; do
git tag --delete $tag
done
# Now create the version and release tag from the specfile
RELEASE=`rpm --queryformat '%{release}\n' --specfile $NAME.spec | head -n 1`
VERSION_RELEASE=`rpm --queryformat '%{version} %{release}\n' --specfile $REPO_NAME.spec`
VERSION=${VERSION_RELEASE% *}
RELEASE=${VERSION_RELEASE#* }
# Release is not reliable - if you run on Rocky it comes back EL8, centos 7 - EL7
# So, we need to just take the build part (first word)
TAG=$VERSION"-"${RELEASE%.*}
git tag -a $TAG -m "Setting tag to current Version-Release in spec file: $TAG"
git push origin $TAG $QUIET
git push --tags origin $QUIET
echo "Created $1 Repo: $HTTP_URL - Comment:$COMMENT tag:$TAG"
echo "Current $ORGGITEA/REPO_NAME tagged as $TAG - old tags removed"
exit 0