Compare commits

..

No commits in common. "fd798e83c3e98deb9876902acf7564809c8dbbb0" and "6e9f8dddb9761336bf7c2b25c906189baac7cdac" have entirely different histories.

3 changed files with 21 additions and 190 deletions

View File

@ -138,11 +138,7 @@ optional: (in any order)
* \<local\> used with org= and will use local GITEA instance, default remote - will be passed to \<script\> * \<local\> used with org= and will use local GITEA instance, default remote - will be passed to \<script\>
* \<noisy\> show line being executed * \<noisy\> show line being executed
* \<debug\> run in debug mode * \<debug\> run in debug modea
* \<draft\> create a draft release
* \<prerelease\> create a pre-release
Note that no release type will give a full stable release
Does: Does:

View File

@ -1,121 +0,0 @@
#!/bin/bash
# Pull in parameters from a ini file
#
# 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 $inifilename or /etc/smegit.ini"
echo "git-list-all-org-repos.sh <organisation> [draftrelease | prerelease | release] [cloneurl] [zipurl]"
exit 1
else
inifilename="/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"
GITEAUser=${remote_USER}
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
GITEAHOST=${remote_GITEAHOST}
NOISY=
EXTRAPARAMS=
DEBUG=
for param in $2 $3 $4 $5 $6 $7 $8 $9 $10; do
if [ $param ] ; then
case $param in
local )
GITEAUser=${local_USER}
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
GITEAHOST=${local_GITEAHOST}
;;
debug )
DEBUG=true ;;
noisy )
NOISY=true ;;
release )
SHOWRELEASE=true;SHOWPRERELEASE=false;SHOWDRAFT=false ;;
draftrelease )
SHOWRELEASE=true;SHOWPRERELEASE=false;SHOWDRAFT=true ;;
prerelease )
SHOWRELEASE=true;SHOWPRERELEASE=true;SHOWDRAFT=false ;;
allreleases )
SHOWRELEASE=true;SHOWPRERELEASE=true;SHOWDRAFT=true ;;
cloneurl )
SHOWCLONEURL=true ;;
zipurl )
SHOWZIPURL=true ;;
id )
SHOWID=true ;;
* )
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
esac
else
break
fi
done
if [[ -z $1 ]] ; then
echo "git-list-all-org-repos.sh <organisation> [draftrelease | prerelease | release] [cloneurl] [zipurl]"
exit 0
fi
ORG_NAME="$1"
PAGE_COUNTER=1
REPO_LIST=""
while true; do
REPO_PAGE=$(curl -s -H "Authorization: token $GITEAACCESSTOKEN" "$GITEAHOST/api/v1/orgs/$ORG_NAME/repos?page=$PAGE_COUNTER")
if [[ $(echo $REPO_PAGE | jq length) -eq 0 ]]; then
break
fi
REPO_LIST="$REPO_LIST $(echo $REPO_PAGE | jq -r .[].full_name | cut -d / -f 2 )"
PAGE_COUNTER=$((PAGE_COUNTER+1))
done
REPO_LIST=$(echo $REPO_LIST | tr -s '[:space:]' '\n' | sort)
for item in $REPO_LIST ; do
line=$item
if [[ $SHOWID || $SHOWRELEASE || $SHOWCLONEURL || $ZIPURL ]] ; then
#Find and show releases
# echo "$GITEAHOST/api/v1/repos/$ORG_NAME/$item/releases?draft=true&pre-release=true&limit=100" \
# -H 'accept: application/json' \
# -H "Authorization: token $GITEAACCESSTOKEN"
RESPONSE=$(curl -s -X 'GET' \
"$GITEAHOST/api/v1/repos/$ORG_NAME/$item/releases?draft=$SHOWDRAFT&pre-release=SHOWPRERELEASE&limit=100" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN")
if [ $DEBUG ] ; then echo "$RESPONSE"; fi
if [ $SHOWRELEASE ] ; then
# Will need to use " jq 'map(.name)'" once we have more than one release.
REL=$(echo $RESPONSE | jq -r '.[0].tag_name')
ID=$(echo $RESPONSE | jq -r '.[0].id')
if [ $DEBUG ] ; then echo $REL; fi
if [ "$REL" ] ; then line="$line\t$REL($ID)";
else line="$line\tnone";fi
if [ $SHOWCLONEURL ] ; then
URL=$(echo $RESPONSE | jq -r '.[0].url')
if [ "$URL" ] ; then line="$line\t$URL"; fi
fi
if [ $SHOWZIPURL ] ; then
URL=$(echo $RESPONSE | jq -r '.[0].zipball_url')
if [ "$URL" ] ; then line="$line\t$URL"; fi
fi
fi
fi
echo -e $line;
done

View File

@ -7,7 +7,7 @@
# #
# #
if [[ -z $1 ]] ; then if [[ -z $1 ]] ; then
echo "git-make-release <modulename> <organization> <release> [local] [debug] [noisy] [draft] [prerelease]" echo "************make-release <modulename> <organization> <release> [local] [debug] [noisy]"
exit 0 exit 0
fi fi
@ -19,7 +19,7 @@ if [ ! -e $inifilename ] ; then
# Not here, look at system default # Not here, look at system default
if [ ! -e /etc/smegit.ini ] ; then if [ ! -e /etc/smegit.ini ] ; then
echo "No ini file found $inifiename or /etc/smegit.ini" echo "No ini file found $inifiename or /etc/smegit.ini"
echo "git-make-release <modulename> <organization> <release> [local] [debug] [noisy] [draft] [prerelease]" echo "make-release <modulename> <organization> <release> [local] [debug] [noisy]"
exit 1 exit 1
else else
initfilename="/etc/smegit.ini" initfilename="/etc/smegit.ini"
@ -48,8 +48,6 @@ GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
GITEAHOST=${remote_GITEAHOST} GITEAHOST=${remote_GITEAHOST}
NOISY= NOISY=
EXTRAPARAMS= EXTRAPARAMS=
MAKEPRE=false
MAKEDRAFT=false
for param in $4 $5 $6; do for param in $4 $5 $6; do
if [ $param ] ; then if [ $param ] ; then
case $param in case $param in
@ -62,12 +60,6 @@ for param in $4 $5 $6; do
DEBUG=true ;; DEBUG=true ;;
noisy ) noisy )
NOISY=true ;; NOISY=true ;;
draft )
MAKEDRAFT=true ;;
prerelease )
MAKEPRE=true ;;
draftpre )
MAKEPRE=true;MAKEDRAFT=true ;;
* ) * )
EXTRAPARAMS=$EXTRAPARAMS" "$param ;; EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
esac esac
@ -76,7 +68,6 @@ for param in $4 $5 $6; do
fi fi
done done
if [ $DEBUG ] ; then echo "draft:$MAKEDRAFT*pre:$MAKEPRE"; fi
#check for release tag #check for release tag
if [ -z $3 ]; then if [ -z $3 ]; then
echo "Release tag not set"; echo "Release tag not set";
@ -110,7 +101,7 @@ RemoteRepoURL="$GITEAHOST/$2/$1"
if [ $DEBUG ] ; then echo "URL="$RemoteRepoURL; fi if [ $DEBUG ] ; then echo "URL="$RemoteRepoURL; fi
# First see if release exists: # First see if release exists:
RESPONSE=$(curl -s -X 'GET' \ RESPONSE=$(curl -X 'GET' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/tags/SME$3" \ "$GITEAHOST/api/v1/repos/$2/$1/releases/tags/SME$3" \
-H 'accept: application/json') -H 'accept: application/json')
if [ $DEBUG ] ; then echo "See if Release exists response="$RESPONSE; fi if [ $DEBUG ] ; then echo "See if Release exists response="$RESPONSE; fi
@ -136,56 +127,21 @@ fi
if [[ -z "$ID" ]]; then if [[ -z "$ID" ]]; then
# Create Release # Create Release
if [ $NOISY ]; then echo "Creating Release $3 for $2/$1"; fi if [ $NOISY ]; then echo "Creating Release $3 for $2/$1"; fi
# 3 branches 'cos I can't get the ascaping correct for using $MAKEPRE and $MAKEDRAFT in the -d json parameter to curl! RESPONSE=$(curl -X 'POST' \
if [ $MAKEDRAFT = "true" ]; then "$GITEAHOST/api/v1/repos/$2/$1/releases" \
if [ $DEBUG ] ; then echo "$MAKEDRAFT:Creating draft release"; fi -H 'accept: application/json' \
RESPONSE=$(curl -s -X 'POST' \ -H "Authorization: token $GITEAACCESSTOKEN" \
"$GITEAHOST/api/v1/repos/$2/$1/releases" \ -H 'Content-Type: application/json' \
-H 'accept: application/json' \ -d '{
-H "Authorization: token $GITEAACCESSTOKEN" \ "body": "'"1st Release of rpm built from git - `date` "'",
-H 'Content-Type: application/json' \ "draft": true,
-d '{ "name": "'"$1"'",
"body": "'"1st Draft Release of rpm built from git - `date` "'", "prerelease": true,
"draft": true, "tag_name": "'SME"$3"'",
"name": "'"$1"'", "target_commitish": ""
"prerelease": false, }')
"tag_name": "'SME"$3"'",
"target_commitish": ""}'
);
elif [ $MAKEPRE = "true" ]; then
if [ $DEBUG ] ; then echo "Creating pre-release"; fi
RESPONSE=$(curl -s -X 'POST' \
"$GITEAHOST/api/v1/repos/$2/$1/releases" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \
-H 'Content-Type: application/json' \
-d '{
"body": "'"1st Pre-Release of rpm built from git - `date` "'",
"draft": false,
"name": "'"$1"'",
"prerelease": true,
"tag_name": "'SME"$3"'",
"target_commitish": ""}'
);
else
if [ $DEBUG ] ; then echo "Creating full release"; fi
RESPONSE=$(curl -s -X 'POST' \
"$GITEAHOST/api/v1/repos/$2/$1/releases" \
-H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \
-H 'Content-Type: application/json' \
-d '{
"body": "'"1st Stable Release of rpm built from git - `date` "'",
"draft": false,
"name": "'"$1"'",
"prerelease": false,
"tag_name": "'SME"$3"'",
"target_commitish": ""}'
);
fi
# Extract id from release # Extract id from release
if [ $DEBUG ]; then echo "Create Release response="$RESPONSE; fi if [ $DEBUG ]; then echo "Create Release response="$RESPONSE; fi
exit 0
ID=$(echo $RESPONSE | jq -r '.id') ID=$(echo $RESPONSE | jq -r '.id')
if [[ -z $ID ]] ; then if [[ -z $ID ]] ; then
echo "Unable to create release for $2/$1 ($3)" echo "Unable to create release for $2/$1 ($3)"
@ -195,14 +151,14 @@ else
if [ $NOISY ]; then echo "Found Release $ID for $2/$1 ($3)"; fi if [ $NOISY ]; then echo "Found Release $ID for $2/$1 ($3)"; fi
fi fi
if [ $DEBUG ] ; then echo "ID:"$ID; fi if [ $DEBUG ] ; then echo "ID:"$ID; fi
exit 0
# And use it to upload the rpm and src rpm # And use it to upload the rpm and src rpm
cd $WORKDIR/$2/$1 cd $WORKDIR/$2/$1
# Got to cd to rpm directory here # Got to cd to rpm directory here
RPMDIR=$(ls $(basename `pwd`)*.rpm | sort | head -n 1 | sed 's/.src.rpm//' | sed 's/\./_/g') RPMDIR=$(ls $(basename `pwd`)*.rpm | sort | head -n 1 | sed 's/.src.rpm//' | sed 's/\./_/g')
echo $RPMDIR echo $RPMDIR
# List the existing attachments # List the existing attachments
ASSETSRESPONSE=$(curl -s -X 'GET' \ ASSETSRESPONSE=$(curl -X 'GET' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets" \ "$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets" \
-H 'accept: application/json') -H 'accept: application/json')
if [ $DEBUG ]; then echo "Asset response:"$ASSETSRESPONSE; fi if [ $DEBUG ]; then echo "Asset response:"$ASSETSRESPONSE; fi
@ -223,7 +179,7 @@ for File in $(ls $RPMDIR/*.rpm) ; do
#echo "ATTID:"$ATTID #echo "ATTID:"$ATTID
ATTID=$(echo $ATTID | sed 's/\[//' | sed 's/\]//' | sed 's/ //g') ATTID=$(echo $ATTID | sed 's/\[//' | sed 's/\]//' | sed 's/ //g')
if [ $DEBUG ]; then echo "ATTID:"$ATTID; fi if [ $DEBUG ]; then echo "ATTID:"$ATTID; fi
RESPONSE=$(curl -s -X 'DELETE' \ RESPONSE=$(curl -X 'DELETE' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets/$ATTID" \ "$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets/$ATTID" \
-H "Authorization: token $GITEAACCESSTOKEN" \ -H "Authorization: token $GITEAACCESSTOKEN" \
-H 'accept: application/json') -H 'accept: application/json')
@ -239,7 +195,7 @@ for File in $(ls $RPMDIR/*.rpm) ; do
# Then send current version # Then send current version
FULLFILENAME=$FULLPATH/$File FULLFILENAME=$FULLPATH/$File
if [ $DEBUG ] ; then echo $FULLFILENAME; fi if [ $DEBUG ] ; then echo $FULLFILENAME; fi
RESPONSE=$(curl -s -X 'POST' \ RESPONSE=$(curl -X 'POST' \
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets?name=$BASEFile" \ "$GITEAHOST/api/v1/repos/$2/$1/releases/$ID/assets?name=$BASEFile" \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \ -H "Authorization: token $GITEAACCESSTOKEN" \