Add release types to make-release

This commit is contained in:
Brian Read 2023-07-19 12:22:50 +01:00
parent 477ecb7c4d
commit fd798e83c3
2 changed files with 61 additions and 19 deletions

View File

@ -138,7 +138,11 @@ 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 modea * \<debug\> run in debug mode
* \<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

@ -66,6 +66,8 @@ for param in $4 $5 $6; do
MAKEDRAFT=true ;; MAKEDRAFT=true ;;
prerelease ) prerelease )
MAKEPRE=true ;; MAKEPRE=true ;;
draftpre )
MAKEPRE=true;MAKEDRAFT=true ;;
* ) * )
EXTRAPARAMS=$EXTRAPARAMS" "$param ;; EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
esac esac
@ -74,6 +76,7 @@ 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";
@ -107,7 +110,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 -X 'GET' \ RESPONSE=$(curl -s -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
@ -133,21 +136,56 @@ 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
RESPONSE=$(curl -X 'POST' \ # 3 branches 'cos I can't get the ascaping correct for using $MAKEPRE and $MAKEDRAFT in the -d json parameter to curl!
if [ $MAKEDRAFT = "true" ]; then
if [ $DEBUG ] ; then echo "$MAKEDRAFT:Creating draft release"; fi
RESPONSE=$(curl -s -X 'POST' \
"$GITEAHOST/api/v1/repos/$2/$1/releases" \ "$GITEAHOST/api/v1/repos/$2/$1/releases" \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H "Authorization: token $GITEAACCESSTOKEN" \ -H "Authorization: token $GITEAACCESSTOKEN" \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{ -d '{
"body": "'"1st Release of rpm built from git - `date` "'", "body": "'"1st Draft Release of rpm built from git - `date` "'",
"draft": "'"$MAKEDRAFT"'", "draft": true,
"name": "'"$1"'", "name": "'"$1"'",
"prerelease": "'"$MAKEPRE"'", "prerelease": false,
"tag_name": "'SME"$3"'", "tag_name": "'SME"$3"'",
"target_commitish": "" "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)"
@ -157,14 +195,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 -X 'GET' \ ASSETSRESPONSE=$(curl -s -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
@ -185,7 +223,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 -X 'DELETE' \ RESPONSE=$(curl -s -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')
@ -201,7 +239,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 -X 'POST' \ RESPONSE=$(curl -s -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" \