Skip to content

Instantly share code, notes, and snippets.

@alexnederlof
Last active December 21, 2015 21:48
Show Gist options
  • Save alexnederlof/6370667 to your computer and use it in GitHub Desktop.
Save alexnederlof/6370667 to your computer and use it in GitHub Desktop.
Automatic deployment of your latest Latex (or other) PDF to Amazon S3. The script adds the latest git describe output to the title so that if someone reviews and annotates it, you know which version it was.
#!/bin/bash
#####
#
# Deploy a PDF file annotated with the latest git version
# to your Amazon S3 bucket.
#
# This script requires you are running on a Mac with
# homebrew installed and a S3 bucket setup.
#
# Hook this to your pre-push stage by creating a script
# in .git/hooks/pre-push with one command "bash deploy.sh"
#
####
## Setting
FILE=yourFile.pdf # You file
BUCKET=s3://your.s3bucket.com # The bucket name
TITLE="My awesome doc" # The document title
## Script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
command -v brew >/dev/null 2>&1 || { echo >&2 "I require HomeBrew but it's not installed. Aborting."; exit 1; }
command -v s3cmd >/dev/null 2>&1 || { echo "Installing S3 Deploy dependency via brew..."; brew install s3cmd; echo "Installed s3cmd";}
command -v exiftool >/dev/null 2>&1 || { echo "Installing exiftool dependency via brew..."; brew install exiftool; echo "Installed exiftool";}
if [ ! -f ~/.s3cfg ] ; then
s3cmd --configure
else
echo "Configuration in place"
fi
version=$(git describe --always --dirty)
echo "Adding the GIT version number $version"
exiftool -Title="$TITLE @ $version" -overwrite_original $FILE
echo "Deploying to S3"
s3cmd put --acl-public $DIR/$FILE $BUCKET/$FILE
echo "Deploy complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment