language: r
addons:
  apt:
    packages:
    - poppler-utils
install: tlmgr install mdframed mweights needspace sourcecodepro sourcesanspro collection-fontsextra pdfjam
script: |
  # Generate epub
  pandoc --verbose pandoc-metadata.yaml README.md [0-9]*.md -o hackerspace-blueprint.epub --metadata date="`date --iso-8601=date`" --toc-depth=2 --epub-embed-font='epub-fonts/*.ttf' --css=epub.css
  # Generate PDF
  pandoc --verbose pandoc-metadata.yaml README.md [0-9]*.md -o hackerspace-blueprint.pdf --metadata date="`date --iso-8601=date`" --template eisvogel.tex --include-before-body=include-cover.tex --include-after-body=include-back.tex
  # Generate booklet
  numpages=$(pdfinfo hackerspace-blueprint.pdf | awk '/^Pages/ { print $2}')
  pdfbook hackerspace-blueprint.pdf 2-$(($numpages-2)) -o hackerspace-blueprint-booklet-body.pdf
deploy:
  provider: releases
  api_key:
    secure: cIRIKuDWejK79Kojh2URkQBmQcKDJtH/MmrzgCySQ7ArjbZ6/cPkS014QbNmUft4GiRGZzIiulfkkvLtdT4UVGVXEw7gTK/V5b6bEci6fst4rDPL/hCDeXcLutOxcOwb7vei38V5XhE+1D2UcFQFNJFkeo60WKWR9ybIQ7pAemo=
  file:
    - hackerspace-blueprint.epub
    - hackerspace-blueprint.pdf
    - hackerspace-blueprint-booklet-cover.pdf
    - hackerspace-blueprint-booklet-body.pdf
  skip_cleanup: true
  on:
    repo: "0x20/hackerspace-blueprint"
if:
  tag IS blank
