Add in update and delete release scripts

master
Brian Read 10 months ago
parent 307a492847
commit 70daf74b8d

@ -170,3 +170,23 @@ optional: (in any order)
Does:
Display a "table" of each repo and the optional extras requested.
## git-update-release-in-one-repo.sh
Update the release (draft/prerelease/release)
git-update-release-in-one-repo.sh <organisation> <repo> [ <releasetag> | <id> ] [draft|prerelease|release] [local] [debug]
* \<organisation\> can be any organisation or user on the remote or local GITEA instance
* \<repo\> name of the repo (package)
* \<releasetag\> Full tag of the release (inc SME if applicable)
* \<id\>
* draft|prerelease|release
optional: (in any order)
* \<local\> used with org= and will use local GITEA instance, default remote - will be passed to \<script\>
* \<debug\> run in debug mode
Does:
Resets the release specified to the type specified.

@ -0,0 +1,84 @@
#!/bin/bash
#
# git-delete-release-in-one-rep.sh <organisation> <repo> [ <releasetag> | <id> ]
#
# Create the release (deleting one that is the same tag),
# then uploads the .src.rpm and .rpm as an attachment (deleting any one of the same name)
#
#
if [[ -z $1 ]] ; then
echo "git-delete-release-in-one-rep.sh <organisation> <repo> <organisation> <repo> [ <releasetag> | <id> ] [local] [debug]"
exit 0
fi
#
# Pull in parameters from a config file ~/.smegit/config
#
inifilename=$(echo ~)"/.smegit/config"
if [ ! -e $inifilename ] ; then
# Not here, look at system default
if [ ! -e /etc/smegit.ini ] ; then
echo "No ini file found $inifiename or /etc/smegit.ini"
echo "git-delete-release-in-one-rep.sh <organisation> <repo> <organisation> <repo> [ <releasetag> | <id> ] [local] [debug]"
exit 1
else
initfilename="/etc/smegit.ini"
fi
fi
while read -r line || [[ -n "$line" ]]; do
if [[ $line =~ ^\[.*\]$ ]]
then
section=${line#*[}
section=${section%]*}
else
if [[ $line =~ ^[^#]*= ]]
then
key=${line%=*}
value=${line#*=}
declare "${section}_${key}=$value"
fi
fi
done < "$inifilename"
DEBUG=
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
GITEAUser=${remote_USER}
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
GITEAHOST=${remote_GITEAHOST}
for param in $2 $3 $4 $5 $6 $7; do
if [ $param ] ; then
case $param in
local )
GITEAUser=${local_USER}
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
GITEAHOST=${local_GITEAHOST}
;;
debug )
DEBUG=true ;;
* )
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
esac
else
break
fi
done
# Uses if ist char is numeric to see if an id or tag is provided
if [[ ! "${3:0:1}" =~ [0-9] ]]; then
# <organisation> <repo> <releasetag> - find the id from the info provided
ID=999;
# TBD
else
ID=$3;
fi
if [ $DEBUG ]; then echo "I:$ID"; fi
# And then delete it by id.
RESPONSE=$(curl -s -X 'DELETE' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN")
if [ $DEBUG ]; then echo "$RESPONSE"; fi
exit 0

@ -0,0 +1,121 @@
#!/bin/bash
#
# git-update-release-in-one-repo.sh <organisation> <repo> [ <releasetag> | <id> ] [draft|prerelease|release]
#
# Create the release (deleting one that is the same tag),
# then uploads the .src.rpm and .rpm as an attachment (deleting any one of the same name)
#
#
if [[ -z $1 ]] ; then
echo "git-update-release-in-one-repo.sh <organisation> <repo> [ <releasetag> | <id> ] [draft|prerelease|release] [local] [debug]"
exit 0
fi
if [[ -z $4 ]] ; then
echo "Must provide release type"
echo "git-update-release-in-one-repo.sh <organisation> <repo> [ <releasetag> | <id> ] [draft|prerelease|release] [local] [debug]"
exit 0
fi
#
# Pull in parameters from a config file ~/.smegit/config
#
inifilename=$(echo ~)"/.smegit/config"
if [ ! -e $inifilename ] ; then
# Not here, look at system default
if [ ! -e /etc/smegit.ini ] ; then
echo "No ini file found $inifiename or /etc/smegit.ini"
echo "git-update-release-in-one-repo.sh <organisation> <repo> [ <releasetag> | <id> ] [draft|prerelease|release] [local] [debug]"
exit 1
else
initfilename="/etc/smegit.ini"
fi
fi
while read -r line || [[ -n "$line" ]]; do
if [[ $line =~ ^\[.*\]$ ]]
then
section=${line#*[}
section=${section%]*}
else
if [[ $line =~ ^[^#]*= ]]
then
key=${line%=*}
value=${line#*=}
declare "${section}_${key}=$value"
fi
fi
done < "$inifilename"
DEBUG=
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
GITEAUser=${remote_USER}
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
GITEAHOST=${remote_GITEAHOST}
for param in $2 $3 $4 $5 $6 $7; do
if [ $param ] ; then
case $param in
local )
GITEAUser=${local_USER}
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
GITEAHOST=${local_GITEAHOST}
;;
debug )
DEBUG=true ;;
* )
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
esac
else
break
fi
done
# Uses if ist char is numeric to see if an id or tag is provided
if [[ ! "${3:0:1}" =~ [0-9] ]]; then
# <organisation> <repo> <releasetag> - find the id from the info provided
ID=999;
# TBD
else
ID=$3;
fi
if [ $DEBUG ]; then echo "I:$ID"; fi
# And then edit it by id.
if [ $4 = "draft" ]; then
RESPONSE=$(curl -s -X 'PATCH' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \
-H 'Content-Type: application/json' \
-d '{
"draft": true,
"prerelease": false
}')
elif [ $4 = "prerelease" ]; then
RESPONSE=$(curl -s -X 'PATCH' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \
-H 'Content-Type: application/json' \
-d '{
"draft": false,
"prerelease": true
}')
else
RESPONSE=$(curl -s -X 'PATCH' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \
-H 'Content-Type: application/json' \
-d '{
"draft": false,
"prerelease": false
}')
fi
if [ $DEBUG ]; then echo "$RESPONSE"; fi
exit 0
Loading…
Cancel
Save