On Mon, Jan 15, 2018 at 11:12 AM, Aaron Armstrong Skomra
<sko...@gmail.com> wrote:
> Require at least 1 of Github/Sourceforge.
>

Add something like the following tag here for tracking:

Ref: https://github.com/linuxwacom/xf86-input-wacom/issues/10

> Signed-off-by: Aaron Armstrong Skomra <sko...@gmail.com>
> ---
> Similar patches were applied to input-wacom in October. This
> revised patch addresses Peter's comments. I will revise input-wacom's
> release.sh when this series is accepted here.
>
>  release.sh | 279 
> +++++++++++++++++++++++++++++++++++++++++++------------------
>  1 file changed, 197 insertions(+), 82 deletions(-)
>
> diff --git a/release.sh b/release.sh
> index a5dff324cc9d..f6102206469c 100755
> --- a/release.sh
> +++ b/release.sh
> @@ -89,11 +89,160 @@ fi
>  }
>
>  
> #------------------------------------------------------------------------------
> +#                      Function: release_to_sourceforge
> +#------------------------------------------------------------------------------
> +#
> +release_to_sourceforge () {
> +
> +    # Some hostnames are also used as /srv subdirs
> +    host_linuxwacom="shell.sourceforge.net"
> +
> +    section_path=archive/individual/$section
> +    srv_path="/srv/$host_current/$section_path"
> +
> +    if [ x"$section" = xxf86-input-wacom ] ||
> +       [ x"$section" = xinput-wacom ] ||
> +       [ x"$section" = xlibwacom ]; then
> +        # input-wacom files are in a subdirectory for whatever reason
> +        if [ x"$section" = xinput-wacom ]; then
> +            section="xf86-input-wacom/input-wacom"
> +        fi
> +
> +        hostname=$host_linuxwacom
> +        host_current="sourceforge.net"
> +        section_path="projects/linuxwacom/files/$section"
> +        srv_path="/home/frs/project/linuxwacom/$section"
> +
> +        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 ${SF_USERNAME%@},linuxwacom@$hostname create
> +        #echo "Sleeping for 30 seconds, because this sometimes helps against 
> sourceforge's random authentication denials"
> +        #sleep 30
> +    fi
> +
> +    # Use personal web space on the host for unit testing (leave commented 
> out)
> +    # srv_path="~/public_html$srv_path"
> +
> +    # Check that the server path actually does exist
> +    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
> +       return 1
> +    fi
> +
> +    # Check for already existing tarballs
> +    for tarball in $targz $tarbz2 $tarxz; do
> +       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."
> +           else
> +               echo "Error: tarball $tar_name already exists. Use --force to 
> overwrite."
> +               cd $top_src
> +               return 1
> +           fi
> +       fi
> +    done
> +
> +    # 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 
> $SF_USERNAME$hostname:$srv_path
> +       if [ $? -ne 0 ]; then
> +           echo "Error: the tarballs uploading failed."
> +           cd $top_src
> +           return 1
> +       fi
> +    else
> +       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";
> +}
> +
> +#------------------------------------------------------------------------------
> +#                      Function: check_json_message
> +#------------------------------------------------------------------------------
> +#
> +# if we get json with a "message" from github there was an error
> +# $1 the JSON to parse
> +check_json_message() {
> +
> +    message=`echo $1 | jq ".message"`
> +    if [ "$message" != "null" ] ; then
> +        echo "Github release error: $1"
> +        exit 1
> +    fi
> +}
> +
> +#------------------------------------------------------------------------------
> +#                      Function: release_to_github
> +#------------------------------------------------------------------------------
> +#
> +release_to_github() {
> +    # Creating a release on Github automatically creates a tag.
> +
> +    # 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
> +
> +    GH_REPO="linuxwacom"
> +    PROJECT="xf86-input-wacom"
> +    release_description="Temporary Empty Release Description"
> +    release_descr=$(jq -n --arg release_description "$release_description" 
> '$release_description')
> +
> +    # Create a Release
> +    api_json=$(printf '{"tag_name": "%s",
> +                        "target_commitish": "master",
> +                        "name": "%s",
> +                        "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/$PROJECT/releases`
> +    GH_RELEASE_ID=`echo $create_result | jq '.id'`
> +
> +    check_json_message "$create_result"
> +
> +    # Upload the tar to the release
> +    upload_result=`curl -s -u $GH_USERNAME \
> +        -H "Content-Type: application/x-bzip" \
> +        --data-binary @$tarbz2 \
> +        
> "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"
> +
> +    # Upload the sig to the release
> +    sig_result=`curl -s -u $GH_USERNAME \
> +        -H "Content-Type: application/pgp-signature" \
> +        --data-binary @$tarbz2.sig \
> +        
> "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"
> +
> +    echo "Github release created"
> +}
> +
> +#------------------------------------------------------------------------------
>  #                      Function: generate_announce
>  
> #------------------------------------------------------------------------------
>  #
>  generate_announce()
>  {
> +    MD5SUM=`which md5sum || which gmd5sum`
> +    SHA1SUM=`which sha1sum || which gsha1sum`
> +    SHA256SUM=`which sha256sum || which gsha256sum`
> +
>      cat <<RELEASE
>  Subject: [ANNOUNCE] $pkg_name $pkg_version
>  To: $list_to
> @@ -105,16 +254,14 @@ git tag: $tag_name
>
>  RELEASE
>
> -    for tarball in $tarbz2 $targz $tarxz; do
>         cat <<RELEASE
> -http://$host_current/$section_path/$tarball
> +$DL_URL
>  MD5:  `$MD5SUM $tarball`
>  SHA1: `$SHA1SUM $tarball`
>  SHA256: `$SHA256SUM $tarball`
> -PGP:  http://${host_current}/${section_path}/${tarball}.sig
> +PGP: $PGP_URL
>
>  RELEASE
> -    done
>  }
>
>  
> #------------------------------------------------------------------------------
> @@ -221,7 +368,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 "/mesa/.*" -e 
> "/xcb/.*" -e "/xkeyboard-config" -e "/nouveau/xf86-video-nouveau" -e 
> "/libevdev" -e "/wayland/.*" -e "/evemu" -e "/linuxwacom/.*"`
> +       module_url=`echo "$full_module_url" | $GREP -o -e "linuxwacom/.*"`

Shouldn't this go into the prior patch?

>         if [ $? -eq 0 ]; then
>              module_url=`echo $module_url | cut -d'/' -f2,3`
>         else
> @@ -474,76 +621,6 @@ process_module() {
>         fi
>      fi
>
> -    # --------- Now the tarballs are ready to upload ----------
> -
> -    # Some hostnames are also used as /srv subdirs
> -    host_linuxwacom="shell.sourceforge.net"
> -
> -    section_path=archive/individual/$section
> -    srv_path="/srv/$host_current/$section_path"
> -
> -    if [ x"$section" = xxf86-input-wacom ] ||
> -       [ x"$section" = xinput-wacom ] ||
> -       [ x"$section" = xlibwacom ]; then
> -        # input-wacom files are in a subdirectory for whatever reason
> -        if [ x"$section" = xinput-wacom ]; then
> -            section="xf86-input-wacom/input-wacom"
> -        fi
> -
> -        hostname=$host_linuxwacom
> -        host_current="sourceforge.net"
> -        section_path="projects/linuxwacom/files/$section"
> -        srv_path="/home/frs/project/linuxwacom/$section"
> -        list_to="linuxwacom-annou...@lists.sourceforge.net"
> -        list_cc="linuxwacom-disc...@lists.sourceforge.net"
> -
> -        echo "creating shell on sourceforge for $USER"
> -        ssh -t ${USER_NAME%@},linuxwacom@$hostname create
> -        #echo "Simply log out once you get to the prompt"
> -        #ssh -t ${USER_NAME%@},linuxwacom@$hostname create
> -        #echo "Sleeping for 30 seconds, because this sometimes helps against 
> sourceforge's random authentication denials"
> -        #sleep 30
> -    fi
> -
> -    # Use personal web space on the host for unit testing (leave commented 
> out)
> -    # 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 ||
> -    if [ $? -ne 0 ]; then
> -       echo "Error: the path \"$srv_path\" on the web server does not exist."
> -       cd $top_src
> -       return 1
> -    fi
> -
> -    # Check for already existing tarballs
> -    for tarball in $targz $tarbz2 $tarxz; do
> -       ssh $USER_NAME$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."
> -           else
> -               echo "Error: tarball $tar_name already exists. Use --force to 
> overwrite."
> -               cd $top_src
> -               return 1
> -           fi
> -       fi
> -    done
> -
> -    # 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
> -       if [ $? -ne 0 ]; then
> -           echo "Error: the tarballs uploading failed."
> -           cd $top_src
> -           return 1
> -       fi
> -    else
> -       echo "Info: skipping tarballs uploading in dry-run mode."
> -       echo "      \"$srv_path\"."
> -    fi
> -
>      # 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\":"
> @@ -558,13 +635,20 @@ process_module() {
>         echo "Info: skipped pushing tag \"$tag_name\" to the remote 
> repository in dry-run mode."
>      fi
>
> -    MD5SUM=`which md5sum || which gmd5sum`
> -    SHA1SUM=`which sha1sum || which gsha1sum`
> -    SHA256SUM=`which sha256sum || which gsha256sum`
> +    if [ -n "$SF_USERNAME" ]; then
> +        release_to_sourceforge
> +    fi
> +
> +    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
>
> +    list_to="linuxwacom-annou...@lists.sourceforge.net"
> +    list_cc="linuxwacom-disc...@lists.sourceforge.net"
> +
>      # Git-describe returns only "the most recent tag", it may not be the 
> expected one
>      # However, we only use it for the commit history which will be the same 
> anyway.
>      tag_previous=`git describe --abbrev=0 HEAD^ 2>/dev/null`
> @@ -584,7 +668,26 @@ 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 -----------------
> +
> +    if [ -n "$GH_RELEASE_ID" ]; then
> +        # Read the announce email and then escape it as a string in order to 
> add it to the JSON
> +        read -r -d '' release_description <"$tar_name.announce"
> +        release_descr=$(jq -n --arg release_description 
> "$release_description" '$release_description')
> +        api_json=$(printf '{"tag_name": "%s",
> +                            "target_commitish": "master",
> +                            "name": "%s",
> +                            "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/$PROJECT/releases/$GH_RELEASE_ID`
> +
> +        check_json_message "$create_result"
> +        echo "Git shortlog posted to the release at Github, please edit the 
> release to add a description of what's interesting."
> +    fi
>
>      # --------- Successful completion --------------------------
>      cd $top_src
> @@ -696,11 +799,18 @@ do
>      --no-quit)
>         NO_QUIT=yes
>         ;;
> -    # Username of your fdo account if not configured in ssh
> -    --user)
> +    # 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

Since the "jq" command needed by the Github codepath isn't a standard
Linux utility, perhaps something like the following should be added
here:

if which jq > /dev/null 2>&1; then
    echo "The 'jq' program must be installed to release to Github."
    exit 1
fi

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one  /
(That is to say, eight) to the two,     /
But you can’t take seven from three,    /
So you look at the sixty-fours....

> +       ;;
> +    # Sourceforge username. Optional.
> +    --sourceforge)
>         check_option_args $1 $2
>         shift
> -       USER_NAME=$1
> +       SF_USERNAME=$1
>         ;;
>      --*)
>         echo ""
> @@ -731,6 +841,11 @@ do
>      shift
>  done
>
> +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
>  check_modules_specification
>
> --
> 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

Reply via email to