From 81011c7b588cffdc3739e8eda3ae66ee3bcdb956 Mon Sep 17 00:00:00 2001 From: Jan-Pascal van Best Date: Mon, 23 Apr 2012 19:49:40 +0200 Subject: [PATCH] Made upload.pl a but more generic, added upload.sh script to upload the unix and Windows distributables --- .gitignore | 1 + upload.pl | 55 ++++++++++++++++++++++++++++++++++++++++++++++++------ upload.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 6 deletions(-) create mode 100755 upload.sh diff --git a/.gitignore b/.gitignore index b5fbc8d..1e5b6a9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /tv_grab_nl_java.db.properties *.orig /github-token +.*.swp diff --git a/upload.pl b/upload.pl index f0620e8..848218e 100755 --- a/upload.pl +++ b/upload.pl @@ -2,8 +2,46 @@ use strict; use warnings; use Pithub::Repos::Downloads; +use Getopt::Long; +use File::Basename; -my $version = shift(); +# Perl script to upload file to the github download +# section. Called by upload.sh + +sub usage +{ + print "Unknown option: @_\n" if ( @_ ); + print "usage: program --location PATH [--filename FILENAME] [--description DESC] [--content-type] [--help|-?]\n"; + print " location: file to upload, e.g. \"../tv_grab_nl_java-0.9.1.zip\"\n"; + print " filename: remote filename, defaults to basename of location\n"; + print " description: defaults to \"tv_grab_nl_java release \"\n"; + print " content-type: defaults to \"application/zip\"\n"; + exit; +} + +my ($version, $filename, $location, $description, $content_type, $help); + +#-- prints usage if no command line parameters are passed or there is an unknown +# parameter or help option is passed +usage($ARGV) if ( @ARGV < 1 or + ! GetOptions('help|?' => \$help, + 'filename=s' => \$filename, + 'location=s' => \$location, + 'description:s' => \$description, + 'content-type:s' => \$content_type, + ) or defined $help ); + +die("--location is obligatory") if !defined($location); + +if (!defined($description)) { + $description = "tv_grab_nl_java release $version"; +} +if (!defined($filename)) { + $filename = basename($location); +} +if (!defined($content_type)) { + $content_type = "application/zip"; +} open(TOKENFILE,'github-token'); my $token=; @@ -17,19 +55,24 @@ my $download = Pithub::Repos::Downloads->new( my $result = $download->create( data => { - name => "tv_grab_nl_java-$version.zip", - size => ( stat("../tv_grab_nl_java-$version.zip") )[7], - description => "tv_grab_nl_java release $version" , - content_type => 'application/zip', + name => $filename, + size => ( stat($location) )[7], + description => $description, + content_type => $content_type }, ); if ( $result->success ) { my $upload = $download->upload( result => $result, - file => "../tv_grab_nl_java-$version.zip", + file => $location, ); if ( $upload->is_success ) { printf "The file has been uploaded succesfully and is now available at: %s\n", $result->content->{html_url}; + } else { + printf "Error uploading file\n"; } + +} else { + printf "Error uploading file (2)\n"; } diff --git a/upload.sh b/upload.sh new file mode 100755 index 0000000..f89a394 --- /dev/null +++ b/upload.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +VERSION=$( xsltproc pom_version.xsl pom.xml ) + +if [ "$1" != "--testing" ]; then + if ! head Changelog | grep -q "tv_grab_nl_java-$VERSION"; then + echo "Release $VERSION not found in changelog, please update Changelog first"; + exit 1; + fi +fi + +FILENAME="tv_grab_nl_java-$VERSION.zip" +EXEFILENAME="Setup-tv_grab_nl_java-$VERSION.exe" +ZIPFILE="$PWD/../$FILENAME" +EXEFILE="$PWD/../$EXEFILENAME" + +echo "Uploading $ZIPFILE" +perl ./upload.pl --location "$ZIPFILE" \ + --description "tv_grab_nl_java release $VERSION" \ + --content-type "application/zip" + +echo "Uploading $EXEFILE" +perl ./upload.pl --location "$EXEFILE" \ + --description "tv_grab_nl_java release $VERSION (Windows installer)" \ + --content-type "application/exe" + -- 2.39.5