Signed-off-by: Aaron Armstrong Skomra <sko...@gmail.com> --- release.sh | 88 ++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 34 deletions(-)
diff --git a/release.sh b/release.sh index f8a484321fdd..3ca2f72d9378 100755 --- a/release.sh +++ b/release.sh @@ -15,6 +15,14 @@ export LC_ALL=C #------------------------------------------------------------------------------ +# Function: check_for_jq +#------------------------------------------------------------------------------ +# +check_for_jq() { + command -v jq >/dev/null 2>&1 || { echo >&2 "This script requires jq but it is not installed. Exiting."; exit 1;} +} + +#------------------------------------------------------------------------------ # Function: check_local_changes #------------------------------------------------------------------------------ # @@ -113,10 +121,10 @@ release_to_sourceforge () { section_path="projects/linuxwacom/files/$section" srv_path="/home/frs/project/linuxwacom/$section" - echo "creating shell on sourceforge for $USER_NAME" - ssh ${USER_NAME%@},linuxwacom@$hostname create + echo "creating shell on sourceforge for $SF_USERNAME" + ssh ${SF_USERNAME%@},linuxwacom@$hostname create #echo "Simply log out once you get to the prompt" - #ssh -t ${USER_NAME%@},linuxwacom@$hostname create + #ssh -t ${SF_USERNAME%@},linuxwacom@$hostname create #echo "Sleeping for 30 seconds, because this sometimes helps against sourceforge's random authentication denials" #sleep 30 fi @@ -125,7 +133,7 @@ release_to_sourceforge () { # srv_path="~/public_html$srv_path" # Check that the server path actually does exist - ssh $USER_NAME$hostname ls $srv_path >/dev/null 2>&1 || + ssh $SF_USERNAME$hostname ls $srv_path >/dev/null 2>&1 || if [ $? -ne 0 ]; then echo "Error: the path \"$srv_path\" on the web server does not exist." cd $top_src @@ -134,7 +142,7 @@ release_to_sourceforge () { # Check for already existing tarballs for tarball in $targz $tarbz2 $tarxz; do - ssh $USER_NAME$hostname ls $srv_path/$tarball >/dev/null 2>&1 + ssh $SF_USERNAME$hostname ls $srv_path/$tarball >/dev/null 2>&1 if [ $? -eq 0 ]; then if [ "x$FORCE" = "xyes" ]; then echo "Warning: overwriting released tarballs due to --force option." @@ -149,7 +157,7 @@ release_to_sourceforge () { # Upload to host using the 'scp' remote file copy program if [ x"$DRY_RUN" = x ]; then echo "Info: uploading tarballs to web server:" - scp $targz $tarbz2 $tarxz $siggz $sigbz2 $sigxz $USER_NAME$hostname:$srv_path + scp $targz $tarbz2 $tarxz $siggz $sigbz2 $sigxz $SF_USERNAME$hostname:$srv_path if [ $? -ne 0 ]; then echo "Error: the tarballs uploading failed." cd $top_src @@ -159,6 +167,13 @@ release_to_sourceforge () { echo "Info: skipping tarballs uploading in dry-run mode." echo " \"$srv_path\"." fi + + host_current="sourceforge.net" + section_path="projects/linuxwacom/files/$section" + # DL_URL & PGP_URL will be overwritten by the Github download url if github was + # enabled on the command line + DL_URL="http://$host_current/$section_path/$tarbz2" + PGP_URL="http://$host_current/$section_path/$tarbz2.sig" } #------------------------------------------------------------------------------ @@ -183,12 +198,13 @@ check_json_message() { release_to_github() { # Creating a release on Github automatically creates a tag. - #dependency 'jq' for reading the json github sends us back + # dependency 'jq' for reading the json github sends us back - #note git_username should include the suffix ":KEY" if the user has enabled 2FA - #example skomra:de0e4dc3efbf2d008053027708227b365b7f80bf + # note git_username should include the suffix ":KEY" if the user has enabled 2FA + # example skomra:de0e4dc3efbf2d008053027708227b365b7f80bf - GH_REPO=linuxwacom + GH_REPO="linuxwacom" + PROJECT="input-wacom" release_description="Temporary Empty Release Description" release_descr=$(jq -n --arg release_description "$release_description" '$release_description') @@ -199,7 +215,7 @@ release_to_github() { "body": %s, "draft": false, "prerelease": false}' "$tar_name" "$tar_name" "$release_descr") - create_result=`curl -s --data "$api_json" -u $GH_USERNAME https://api.github.com/repos/$GH_REPO/input-wacom/releases` + create_result=`curl -s --data "$api_json" -u $GH_USERNAME https://api.github.com/repos/$GH_REPO/$PROJECT/releases` GH_RELEASE_ID=`echo $create_result | jq '.id'` check_json_message "$create_result" @@ -208,8 +224,8 @@ release_to_github() { upload_result=`curl -s -u $GH_USERNAME \ -H "Content-Type: application/x-bzip" \ --data-binary @$tarbz2 \ - "https://uploads.github.com/repos/$GH_REPO/input-wacom/releases/$GH_RELEASE_ID/assets?name=$tarbz2"` - GH_DL_URL=`echo $upload_result | jq -r '.browser_download_url'` + "https://uploads.github.com/repos/$GH_REPO/$PROJECT/releases/$GH_RELEASE_ID/assets?name=$tarbz2"` + DL_URL=`echo $upload_result | jq -r '.browser_download_url'` check_json_message "$upload_result" @@ -217,8 +233,8 @@ release_to_github() { sig_result=`curl -s -u $GH_USERNAME \ -H "Content-Type: application/pgp-signature" \ --data-binary @$tarbz2.sig \ - "https://uploads.github.com/repos/$GH_REPO/input-wacom/releases/$GH_RELEASE_ID/assets?name=$tarbz2.sig"` - GH_SIG_URL=`echo $sig_result | jq -r '.browser_download_url'` + "https://uploads.github.com/repos/$GH_REPO/$PROJECT/releases/$GH_RELEASE_ID/assets?name=$tarbz2.sig"` + PGP_URL=`echo $sig_result | jq -r '.browser_download_url'` check_json_message "$sig_result" @@ -246,16 +262,14 @@ git tag: $tag_name RELEASE - for tarball in $tarbz2 $targz $tarxz; do cat <<RELEASE -$GH_DL_URL +$DL_URL MD5: `$MD5SUM $tarball` SHA1: `$SHA1SUM $tarball` SHA256: `$SHA256SUM $tarball` -PGP: $GH_SIG_URL +PGP: $PGP_URL RELEASE - done } #------------------------------------------------------------------------------ @@ -362,7 +376,7 @@ get_section() { module_url=`echo $module_url | cut -d'/' -f3,4` else # The look for mesa, xcb, etc... - module_url=`echo "$full_module_url" | $GREP -o -e "linuxwacom/.*" -e "/linuxwacom/.*" -e "Pinglinux/.*" -e "jigpu/.*" -e "skomra/.*"` + module_url=`echo "$full_module_url" | $GREP -o -e "/linuxwacom/.*"` if [ $? -eq 0 ]; then module_url=`echo $module_url | cut -d'/' -f2,3` else @@ -621,8 +635,6 @@ process_module() { fi fi - # --------- Now the tarballs are ready to upload ---------- - # Pushing the top commit tag to the remote repository if [ x$DRY_RUN = x ]; then echo "Info: pushing tag \"$tag_name\" to remote \"$remote_name\":" @@ -637,11 +649,13 @@ process_module() { echo "Info: skipped pushing tag \"$tag_name\" to the remote repository in dry-run mode." fi - if [ -n "$USER_NAME" ]; then + if [ -n "$SF_USERNAME" ]; then release_to_sourceforge fi - release_to_github + if [ -n "$GH_USERNAME" ]; then + release_to_github + fi # --------- Generate the announce e-mail ------------------ # Failing to generate the announce is not considered a fatal error @@ -668,7 +682,8 @@ process_module() { fi generate_announce > "$tar_name.announce" echo "Info: [ANNOUNCE] template generated in \"$tar_name.announce\" file." - echo " Please pgp sign and send it." + echo " Please edit the .announce file to add a description of what's interesting and then" + echo " pgp sign and send it." # --------- Update the "body" text of the Github release with the .announce file ----------------- @@ -682,10 +697,10 @@ process_module() { "body": %s, "draft": false, "prerelease": false}' "$tar_name" "$tar_name" "$release_descr") - create_result=`curl -s -X PATCH --data "$api_json" -u $GH_USERNAME https://api.github.com/repos/$GH_REPO/input-wacom/releases/$GH_RELEASE_ID` + create_result=`curl -s -X PATCH --data "$api_json" -u $GH_USERNAME https://api.github.com/repos/$GH_REPO/$PROJECT/releases/$GH_RELEASE_ID` check_json_message "$create_result" - echo "Announcement posted to release at Github." + echo "Git shortlog posted to the release at Github, please edit the release to add a description of what's interesting." fi # --------- Successful completion -------------------------- @@ -733,6 +748,9 @@ HELP # Choose which make program to use (could be gmake) MAKE=${MAKE:="make"} +# Check if the json parser 'jq' is installed +check_for_jq + # Choose which grep program to use (on Solaris, must be gnu grep) if [ "x$GREP" = "x" ] ; then if [ -x /usr/gnu/bin/grep ] ; then @@ -798,16 +816,18 @@ do --no-quit) NO_QUIT=yes ;; - # Github username with possible Personal Access Token + # Github username. Optional. Append colon and Personali + # Access Token to username if 2FA is enabled on the user + # account doing the release --github) GH_USERNAME=$2 shift ;; - # Username of your fdo account if not configured in ssh - --user) + # Sourceforge username. Optional. + --sourceforge) check_option_args $1 $2 shift - USER_NAME=$1 + SF_USERNAME=$1 ;; --*) echo "" @@ -838,9 +858,9 @@ do shift done -if [ x$GH_USERNAME = x ] ; then - echo "--github option required" - exit 1 +if [[ x$GH_USERNAME = "x" ]] && [[ x$SF_USERNAME = "x" ]] ; then + echo "At least one of --github or --sourceforge option required"; + exit 1; fi # If no modules specified (blank cmd line) display help -- 2.7.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel