Release notes formatting update (#1634)
This commit is contained in:
parent
c830511f01
commit
b14f82b65f
@ -315,8 +315,8 @@ set -e
|
|||||||
rm -f "$releasesJson"
|
rm -f "$releasesJson"
|
||||||
|
|
||||||
echo " previous Release: $prev_release"
|
echo " previous Release: $prev_release"
|
||||||
echo " previous (?Pre-)release: $prev_any_release"
|
|
||||||
echo " previous Pre-release: $prev_pre_release"
|
echo " previous Pre-release: $prev_pre_release"
|
||||||
|
echo " previous (any)release: $prev_any_release"
|
||||||
|
|
||||||
# add generated items to JSON package-definition contents
|
# add generated items to JSON package-definition contents
|
||||||
jq_arg=".packages[0].platforms[0].version = \"$ver\" | \
|
jq_arg=".packages[0].platforms[0].version = \"$ver\" | \
|
||||||
|
103
tools/deploy.sh
103
tools/deploy.sh
@ -1,5 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
json_escape () {
|
||||||
|
printf '%s' "$1" | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))'
|
||||||
|
#printf '%s' "$1" | php -r 'echo json_encode(file_get_contents("php://stdin"));'
|
||||||
|
}
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
#Cmdline options
|
#Cmdline options
|
||||||
@ -77,6 +83,7 @@ shopt -u nocasematch
|
|||||||
# other lines: converted to bullets
|
# other lines: converted to bullets
|
||||||
# empty lines ignored
|
# empty lines ignored
|
||||||
# if '* ' found as a first char pair, it's converted to '- ' to keep bulleting unified
|
# if '* ' found as a first char pair, it's converted to '- ' to keep bulleting unified
|
||||||
|
echo
|
||||||
echo Preparing release notes
|
echo Preparing release notes
|
||||||
echo -----------------------
|
echo -----------------------
|
||||||
echo "Tag's message:"
|
echo "Tag's message:"
|
||||||
@ -89,14 +96,16 @@ if [ $arrLen > 3 ]; then
|
|||||||
ind=3
|
ind=3
|
||||||
while [ $ind -lt $arrLen ]; do
|
while [ $ind -lt $arrLen ]; do
|
||||||
if [ $ind -eq 3 ]; then
|
if [ $ind -eq 3 ]; then
|
||||||
releaseNotes="#### ${msgArray[ind]}\\n"
|
releaseNotes="#### ${msgArray[ind]}"
|
||||||
|
releaseNotes+=$'\r\n'
|
||||||
else
|
else
|
||||||
oneLine="$(echo -e "${msgArray[ind]}" | sed -e 's/^[[:space:]]*//')"
|
oneLine="$(echo -e "${msgArray[ind]}" | sed -e 's/^[[:space:]]*//')"
|
||||||
|
|
||||||
if [ ${#oneLine} -gt 0 ]; then
|
if [ ${#oneLine} -gt 0 ]; then
|
||||||
if [ "${oneLine:0:2}" == "* " ]; then oneLine=$(echo ${oneLine/\*/-}); fi
|
if [ "${oneLine:0:2}" == "* " ]; then oneLine=$(echo ${oneLine/\*/-}); fi
|
||||||
if [ "${oneLine:0:2}" != "- " ]; then releaseNotes+="- "; fi
|
if [ "${oneLine:0:2}" != "- " ]; then releaseNotes+="- "; fi
|
||||||
releaseNotes+="$oneLine\\n"
|
releaseNotes+="$oneLine"
|
||||||
|
releaseNotes+=$'\r\n'
|
||||||
|
|
||||||
#debug output
|
#debug output
|
||||||
echo " ${oneLine}"
|
echo " ${oneLine}"
|
||||||
@ -104,9 +113,9 @@ if [ $arrLen > 3 ]; then
|
|||||||
fi
|
fi
|
||||||
let ind=$ind+1
|
let ind=$ind+1
|
||||||
done
|
done
|
||||||
echo "<tag's message end>"
|
|
||||||
else
|
else
|
||||||
releaseNotes="#### Release of $varTagName\\n"
|
releaseNotes="#### Release of $varTagName"
|
||||||
|
releaseNotes+=$'\r\n'
|
||||||
|
|
||||||
#debug output
|
#debug output
|
||||||
echo " Release of $varTagName"
|
echo " Release of $varTagName"
|
||||||
@ -114,11 +123,10 @@ fi
|
|||||||
|
|
||||||
# - list of commits (commits.txt must exit in the output dir)
|
# - list of commits (commits.txt must exit in the output dir)
|
||||||
commitFile=$varAssetsDir/commits.txt
|
commitFile=$varAssetsDir/commits.txt
|
||||||
if [ -e "$commitFile" ]; then
|
if [ -s "$commitFile" ]; then
|
||||||
|
|
||||||
releaseNotes+="\\n##### Commits\\n"
|
releaseNotes+=$'\r\n##### Commits\r\n'
|
||||||
|
|
||||||
#debug output
|
|
||||||
echo
|
echo
|
||||||
echo "Commits:"
|
echo "Commits:"
|
||||||
|
|
||||||
@ -126,48 +134,86 @@ if [ -e "$commitFile" ]; then
|
|||||||
for next in `cat $commitFile`
|
for next in `cat $commitFile`
|
||||||
do
|
do
|
||||||
IFS=' ' read -r commitId commitMsg <<< "$next"
|
IFS=' ' read -r commitId commitMsg <<< "$next"
|
||||||
releaseNotes+="- [$commitId](https://github.com/$varRepoSlug/commit/$commitId) $commitMsg\\n"
|
commitLine="- [$commitId](https://github.com/$varRepoSlug/commit/$commitId) $commitMsg"
|
||||||
|
echo " $commitLine"
|
||||||
|
|
||||||
#debug output
|
releaseNotes+="$commitLine"
|
||||||
echo " - [$commitId](https://github.com/$varRepoSlug/commit/$commitId) $commitMsg"
|
releaseNotes+=$'\r\n'
|
||||||
done
|
done
|
||||||
rm -f $commitFile
|
rm -f $commitFile
|
||||||
fi
|
fi
|
||||||
|
|
||||||
releaseNotes=$(perl -pe 's/\r?\n/\\n/' <<< ${releaseNotes})
|
|
||||||
|
|
||||||
# Check possibly existing release for current tag
|
# Check possibly existing release for current tag
|
||||||
echo "Checking for possible releases of current tag $varTagName..."
|
echo
|
||||||
# (eg build invoked by Create New Release GHUI button -> GH default release pack created immediatelly including default assests)
|
echo "Processing GitHub release record for $varTagName:"
|
||||||
|
echo "-------------------------------------------------"
|
||||||
|
|
||||||
|
echo " - check $varTagName possible existence..."
|
||||||
|
|
||||||
|
# (eg build invoked by Create New Release GHUI button -> GH default release pack created immediately including default assests)
|
||||||
HTTP_RESPONSE=$(curl -L --silent --write-out "HTTPSTATUS:%{http_code}" https://api.github.com/repos/$varRepoSlug/releases/tags/$varTagName?access_token=$varAccessToken)
|
HTTP_RESPONSE=$(curl -L --silent --write-out "HTTPSTATUS:%{http_code}" https://api.github.com/repos/$varRepoSlug/releases/tags/$varTagName?access_token=$varAccessToken)
|
||||||
|
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
|
||||||
|
|
||||||
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
|
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
|
||||||
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
|
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
|
||||||
echo " HTTP server response code: $HTTP_STATUS"
|
echo " ---> GitHub server HTTP response: $HTTP_STATUS"
|
||||||
|
|
||||||
# if the release exists, append/update recent files to its assets vector
|
# if the release exists, append/update recent files to its assets vector
|
||||||
if [ $HTTP_STATUS -eq 200 ]; then
|
if [ $HTTP_STATUS -eq 200 ]; then
|
||||||
releaseId=$(echo $HTTP_BODY | jq -r '.id')
|
releaseId=$(echo $HTTP_BODY | jq -r '.id')
|
||||||
echo " - $varTagName release found (id $releaseId)"
|
echo " - $varTagName release found (id $releaseId)"
|
||||||
|
|
||||||
#merge release notes and overwrite pre-release flag. all other attributes remain unchanged
|
#Merge release notes and overwrite pre-release flag. all other attributes remain unchanged:
|
||||||
releaseNotesGH=$(echo $HTTP_BODY | jq -r '.body')
|
|
||||||
releaseNotes="$releaseNotesGH\\n$releaseNotes"
|
|
||||||
|
|
||||||
echo " ... updating release notes and pre-release flag"
|
# 1. take existing notes from server (added by release creator)
|
||||||
|
releaseNotesGH=$(echo $HTTP_BODY | jq -r '.body')
|
||||||
|
|
||||||
|
# - strip possibly trailing CR
|
||||||
|
if [ "${releaseNotesGH: -1}" == $'\r' ]; then
|
||||||
|
releaseNotesTemp="${releaseNotesGH:0:-1}"
|
||||||
|
else
|
||||||
|
releaseNotesTemp="$releaseNotesGH"
|
||||||
|
fi
|
||||||
|
# - add CRLF to make relnotes consistent for JSON encoding
|
||||||
|
releaseNotesTemp+=$'\r\n'
|
||||||
|
|
||||||
|
# 2. #append generated relnotes (usually commit oneliners)
|
||||||
|
releaseNotes="$releaseNotesTemp$releaseNotes"
|
||||||
|
|
||||||
|
# 3. JSON-encode whole string for GH API transfer
|
||||||
|
releaseNotes=$(json_escape "$releaseNotes")
|
||||||
|
|
||||||
|
# 4. remove extra quotes returned by python (dummy but whatever)
|
||||||
|
releaseNotes=${releaseNotes:1:-1}
|
||||||
|
|
||||||
|
#Update current GH release record
|
||||||
|
echo " - updating release notes and pre-release flag:"
|
||||||
|
|
||||||
curlData="{\"body\": \"$releaseNotes\",\"prerelease\": $varPrerelease}"
|
curlData="{\"body\": \"$releaseNotes\",\"prerelease\": $varPrerelease}"
|
||||||
curl --data "$curlData" https://api.github.com/repos/$varRepoSlug/releases/$releaseId?access_token=$varAccessToken
|
echo " <data.begin>$curlData<data.end>"
|
||||||
|
echo
|
||||||
|
#echo "DEBUG: curl --data \"$curlData\" https://api.github.com/repos/$varRepoSlug/releases/$releaseId?access_token=$varAccessToken"
|
||||||
|
|
||||||
|
curl --data "$curlData" https://api.github.com/repos/$varRepoSlug/releases/$releaseId?access_token=$varAccessToken
|
||||||
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
|
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
|
||||||
|
|
||||||
|
echo " - $varTagName release record successfully updated"
|
||||||
|
|
||||||
#... or create a new release record
|
#... or create a new release record
|
||||||
else
|
else
|
||||||
|
releaseNotes=$(json_escape "$releaseNotes")
|
||||||
|
releaseNotes=${releaseNotes:1:-1}
|
||||||
|
|
||||||
|
echo " - release $varTagName not found, creating a new record:"
|
||||||
|
|
||||||
curlData="{\"tag_name\": \"$varTagName\",\"target_commitish\": \"master\",\"name\": \"v$varTagName\",\"body\": \"$releaseNotes\",\"draft\": false,\"prerelease\": $varPrerelease}"
|
curlData="{\"tag_name\": \"$varTagName\",\"target_commitish\": \"master\",\"name\": \"v$varTagName\",\"body\": \"$releaseNotes\",\"draft\": false,\"prerelease\": $varPrerelease}"
|
||||||
|
echo " <data.begin>$curlData<data.end>"
|
||||||
|
|
||||||
#echo "DEBUG: curl --data \"${curlData}\" https://api.github.com/repos/${varRepoSlug}/releases?access_token=$varAccessToken | jq -r '.id'"
|
#echo "DEBUG: curl --data \"${curlData}\" https://api.github.com/repos/${varRepoSlug}/releases?access_token=$varAccessToken | jq -r '.id'"
|
||||||
releaseId=$(curl --data "$curlData" https://api.github.com/repos/$varRepoSlug/releases?access_token=$varAccessToken | jq -r '.id')
|
releaseId=$(curl --data "$curlData" https://api.github.com/repos/$varRepoSlug/releases?access_token=$varAccessToken | jq -r '.id')
|
||||||
echo " - new release created for $varTagName (id $releaseId)"
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
|
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
|
||||||
|
|
||||||
|
echo " - $varTagName release record successfully created (id $releaseId)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Assets defined by dir contents
|
# Assets defined by dir contents
|
||||||
@ -180,19 +226,19 @@ if [ ! -z $varAssetsDir ]; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
|
||||||
echo varAssets: $varAssets
|
|
||||||
|
|
||||||
#Upload additional assets
|
#Upload additional assets
|
||||||
if [ ! -z $varAssets ]; then
|
if [ ! -z $varAssets ]; then
|
||||||
echo
|
echo
|
||||||
echo "Uploading assets:"
|
echo "Uploading assets:"
|
||||||
echo "-----------------"
|
echo "-----------------"
|
||||||
|
echo " Files to upload:"
|
||||||
|
echo " $varAssets"
|
||||||
|
echo
|
||||||
|
|
||||||
curlAuth="Authorization: token $varAccessToken"
|
curlAuth="Authorization: token $varAccessToken"
|
||||||
for filename in $(echo $varAssets | tr ";" "\n")
|
for filename in $(echo $varAssets | tr ";" "\n")
|
||||||
do
|
do
|
||||||
echo " - ${filename}..."
|
echo " - ${filename}:"
|
||||||
curl -X POST -sH "$curlAuth" -H "Content-Type: application/octet-stream" --data-binary @"$filename" https://uploads.github.com/repos/$varRepoSlug/releases/$releaseId/assets?name=$(basename $filename)
|
curl -X POST -sH "$curlAuth" -H "Content-Type: application/octet-stream" --data-binary @"$filename" https://uploads.github.com/repos/$varRepoSlug/releases/$releaseId/assets?name=$(basename $filename)
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
|
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
|
||||||
@ -203,8 +249,3 @@ if [ ! -z $varAssets ]; then
|
|||||||
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
|
||||||
echo
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user