parent
a835bb26c4
commit
9f8f05735b
@ -36,6 +36,8 @@ function downloadAndMergePackageJSON()
|
|||||||
|
|
||||||
#curl --verbose -sH "Authorization: token $curlAuthToken" -L -o "$old_json" "$jsonLink"
|
#curl --verbose -sH "Authorization: token $curlAuthToken" -L -o "$old_json" "$jsonLink"
|
||||||
curl -L -o "$old_json" "$jsonLink?access_token=$curlAuthToken"
|
curl -L -o "$old_json" "$jsonLink?access_token=$curlAuthToken"
|
||||||
|
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
|
||||||
|
|
||||||
|
|
||||||
#curl -L -o "$old_json" "$jsonLink"
|
#curl -L -o "$old_json" "$jsonLink"
|
||||||
|
|
||||||
@ -255,10 +257,7 @@ echo " - creating package ZIP archive (${package_name_zip})..."
|
|||||||
pushd $releaseDir >/dev/null
|
pushd $releaseDir >/dev/null
|
||||||
|
|
||||||
zip -qr $package_name_zip $package_name
|
zip -qr $package_name_zip $package_name
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then echo " !error: failed to create ${package_name_zip} (ZIP errno: $?) => aborting"; exit 1; fi
|
||||||
echo " !error: failed to create ${package_name_zip} (ZIP errno: $?) => aborting"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Calculate SHA sum and size of ZIP archive
|
# Calculate SHA sum and size of ZIP archive
|
||||||
sha=`shasum -a 256 $package_name_zip | cut -f 1 -d ' '`
|
sha=`shasum -a 256 $package_name_zip | cut -f 1 -d ' '`
|
||||||
@ -296,6 +295,7 @@ set +e
|
|||||||
|
|
||||||
releasesJson=$releaseDir/releases.json
|
releasesJson=$releaseDir/releases.json
|
||||||
curl -sH "Authorization: token $curlAuth" https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases > $releasesJson
|
curl -sH "Authorization: token $curlAuth" https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases > $releasesJson
|
||||||
|
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
|
||||||
|
|
||||||
prev_release=$(jq -e -r '. | map(select(.draft == false and .prerelease == false)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name' ${releasesJson})
|
prev_release=$(jq -e -r '. | map(select(.draft == false and .prerelease == false)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name' ${releasesJson})
|
||||||
prev_any_release=$(jq -e -r '. | map(select(.draft == false)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name' ${releasesJson})
|
prev_any_release=$(jq -e -r '. | map(select(.draft == false)) | sort_by(.created_at | - fromdateiso8601) | .[0].tag_name' ${releasesJson})
|
||||||
|
@ -77,6 +77,10 @@ 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 Preparing release notes
|
||||||
|
echo -----------------------
|
||||||
|
echo "Tag's message:"
|
||||||
|
|
||||||
relNotesRaw=`git show -s --format=%b $varTagName`
|
relNotesRaw=`git show -s --format=%b $varTagName`
|
||||||
readarray -t msgArray <<<"$relNotesRaw"
|
readarray -t msgArray <<<"$relNotesRaw"
|
||||||
|
|
||||||
@ -93,12 +97,19 @@ if [ $arrLen > 3 ]; 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\\n"
|
||||||
|
|
||||||
|
#debug output
|
||||||
|
echo " ${oneLine}"
|
||||||
fi
|
fi
|
||||||
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\\n"
|
||||||
|
|
||||||
|
#debug output
|
||||||
|
echo " Release of $varTagName"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# - list of commits (commits.txt must exit in the output dir)
|
# - list of commits (commits.txt must exit in the output dir)
|
||||||
@ -107,11 +118,18 @@ if [ -e "$commitFile" ]; then
|
|||||||
|
|
||||||
releaseNotes+="\\n##### Commits\\n"
|
releaseNotes+="\\n##### Commits\\n"
|
||||||
|
|
||||||
|
#debug output
|
||||||
|
echo
|
||||||
|
echo "Commits:"
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
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"
|
releaseNotes+="- [$commitId](https://github.com/$varRepoSlug/commit/$commitId) $commitMsg\\n"
|
||||||
|
|
||||||
|
#debug output
|
||||||
|
echo " - [$commitId](https://github.com/$varRepoSlug/commit/$commitId) $commitMsg"
|
||||||
done
|
done
|
||||||
rm -f $commitFile
|
rm -f $commitFile
|
||||||
fi
|
fi
|
||||||
@ -124,19 +142,32 @@ echo "Checking for possible releases of current tag $varTagName..."
|
|||||||
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)
|
||||||
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 " HTTP server response code: $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
|
||||||
|
releaseNotesGH=$(echo $HTTP_BODY | jq -r '.body')
|
||||||
|
releaseNotes="$releaseNotesGH\\n$releaseNotes"
|
||||||
|
|
||||||
|
echo " ... updating release notes and pre-release flag"
|
||||||
|
|
||||||
|
curlData="{\"body\": \"$releaseNotes\",\"prerelease\": $varPrerelease}"
|
||||||
|
curl --data "$curlData" https://api.github.com/repos/$varRepoSlug/releases/$releaseId?access_token=$varAccessToken
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
|
||||||
|
|
||||||
#... or create a new release record
|
#... or create a new release record
|
||||||
else
|
else
|
||||||
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 "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)"
|
echo " - new release created for $varTagName (id $releaseId)"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then echo "FAILED: $? => aborting"; exit 1; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Assets defined by dir contents
|
# Assets defined by dir contents
|
||||||
@ -154,13 +185,22 @@ echo varAssets: $varAssets
|
|||||||
|
|
||||||
#Upload additional assets
|
#Upload additional assets
|
||||||
if [ ! -z $varAssets ]; then
|
if [ ! -z $varAssets ]; then
|
||||||
|
echo
|
||||||
|
echo "Uploading assets:"
|
||||||
|
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
|
echo " - ${filename}..."
|
||||||
echo Uploading $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
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "OK"
|
||||||
|
echo
|
||||||
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user