diff --git a/.gitignore b/.gitignore index 92941be2..ac39263a 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,7 @@ __pycache__/ # Misc temporary files *.bak -# Operating system specific files +# System specific files ## Linux *~ @@ -35,3 +35,6 @@ __pycache__/ ## Windows Thumbs.db [Dd]esktop.ini + +## Text Editors +.vscode diff --git a/.travis.yml b/.travis.yml index 63a5a10a..ab7f1609 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ branches: only: - master before_install: - - wget https://repo.continuum.io/miniconda/Miniconda3-4.5.12-Linux-x86_64.sh + - wget https://repo.continuum.io/miniconda/Miniconda3-4.6.14-Linux-x86_64.sh --output-document miniconda.sh - bash miniconda.sh -b -p $HOME/miniconda - source $HOME/miniconda/etc/profile.d/conda.sh @@ -20,11 +20,14 @@ install: - conda list --name manubot - conda activate manubot script: - - sh build/build.sh + - bash build/build.sh cache: directories: - ci/cache -after_success: - - test $TRAVIS_BRANCH = "master" && - test $TRAVIS_EVENT_TYPE = "push" && - sh ci/deploy.sh +deploy: + provider: script + script: bash -o xtrace ci/deploy.sh + skip_cleanup: true + on: + branch: master + condition: $TRAVIS_EVENT_TYPE = "push" diff --git a/README.md b/README.md index b55a178f..0c245743 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ The directories are as follows: + [`content`](content) contains the manuscript source, which includes markdown files as well as inputs for citations and references. See [`USAGE.md`](USAGE.md) for more information. -+ [`output`](output) contains the outputs (generated files) from the manubot including the resulting manuscripts. ++ [`output`](output) contains the outputs (generated files) from Manubot including the resulting manuscripts. You should not edit these files manually, because they will get overwritten. + [`webpage`](webpage) is a directory meant to be rendered as a static webpage for viewing the HTML manuscript. + [`build`](build) contains commands and tools for building the manuscript. @@ -72,23 +72,27 @@ The directories are as follows: ### Local execution -To run the Manubot locally, install the [conda](https://conda.io) environment as described in [`build`](build). -Then, you can build the manuscript on POSIX systems by running the following commands. +The easiest way to run Manubot is to use [continuous integration](#continuous-integration) to rebuild the manuscript when the content changes. +If you want to build a Manubot manuscript locally, install the [conda](https://conda.io) environment as described in [`build`](build). +Then, you can build the manuscript on POSIX systems by running the following commands from this root directory. ```sh # Activate the manubot conda environment (assumes conda version >= 4.4) conda activate manubot # Build the manuscript, saving outputs to the output directory -sh build/build.sh +bash build/build.sh # At this point, the HTML & PDF outputs will have been created. The remaining # commands are for serving the webpage to view the HTML manuscript locally. +# This is required to view local images in the HTML output. # Configure the webpage directory python build/webpage.py -# View the manuscript locally at http://localhost:8000/ +# You can now open the manuscript webpage/index.html in a web browser. +# Alternatively, open a local webserver at http://localhost:8000/ with the +# following commands. cd webpage python -m http.server ``` @@ -97,7 +101,7 @@ Sometimes it's helpful to monitor the content directory and automatically rebuil The following command, while running, will trigger both the `build.sh` and `webpage.py` scripts upon content changes: ```sh -sh build/autobuild.sh +bash build/autobuild.sh ``` ### Continuous Integration diff --git a/USAGE.md b/USAGE.md index 81c744ab..900a94d7 100644 --- a/USAGE.md +++ b/USAGE.md @@ -1,6 +1,8 @@ # Manubot usage guidelines This repository uses [Manubot](https://manubot.org) to automatically produce a manuscript from the source in the [`content`](content) directory. +Check out the [Manubot catalog](https://manubot.org/catalog/) for examples of what is possible when writing with Manubot. +Try editing the [demo manuscript](https://github.com/manubot/try-manubot) to quickly test Manubot formatting and citations. ## Manubot markdown @@ -115,33 +117,51 @@ If `citation-tags.tsv` defines the tag `study-x`, then this study can be cited l ## Reference metadata -The Manubot workflow requires the bibliographic details for references (the set of all cited works) as CSL (Citation Style Language) Items (also known as [citeproc JSON](http://citeproc-js.readthedocs.io/en/latest/csl-json/markup.html#csl-json-items)). -The Manubot attempts to automatically retrieve metadata and generate valid citeproc JSON for references, which is exported to `output/references.json`. -However, in some cases the Manubot fails to retrieve metadata or generates incorrect or incomplete citeproc metadata. +Manubot stores the bibliographic details for references (the set of all cited works) as CSL JSON ([Citation Style Language Items](http://citeproc-js.readthedocs.io/en/latest/csl-json/markup.html#csl-json-items)). +For all citation sources besides `raw`, Manubot automatically generates CSL JSON. +In some cases, automatic metadata retrieval fails or provides incorrect or incomplete information. Errors are most common for `url` references. -For these references, you can manually specify the correct CSL Data in [`content/manual-references.json`](content/manual-references.json), which will override the automatically generated reference data. -To do so, create a new CSL JSON Item that contains the field `"standard_citation"` with the appropriate reference identifier as its value. -The identifier can be obtained from the `standard_citation` column of `citations.tsv`, which is located in the `output` branch or in the `output` subdirectory of local builds. -As an example, `manual-references.json` contains: +Therefore, Manubot supports user-provided metadata, which we refer to as "manual references". +When a manual reference is provided, Manubot uses the supplied metadata and does not attempt to generate it. + +Manubot searches the `content` directory for files that match the glob pattern `manual-references*.*` and expects that these files contain manual references. +[`content/manual-references.json`](content/manual-references.json) is the default file to specify custom CSL JSON metadata. +Manual references are matched to citations using their "id" field. +For example, to manually specify the metadata for the citation `@url:https://github.com/manubot/rootstock`, add a CSL JSON Item to `manual-references.json` that contains the following excerpt: ```json -"standard_citation": "url:https://github.com/greenelab/manubot-rootstock" +"id": "url:https://github.com/manubot/rootstock", ``` -The metadata for `raw` citations must be provided in `manual-references.json` or an error will occur. -For example, to cite `@raw:private-message` in a manuscript, a corresponding CSL Item in `manual-references.json` is required, such as: +The metadata for `raw` citations must be provided in a manual reference file (e.g. `manual-references.json`) or an error will occur. +For example, to cite `@raw:private-message` in a manuscript, a corresponding CSL JSON Item is required, such as: ```json { + "id": "raw:private-message", "type": "personal_communication", - "standard_citation": "raw:private-message", "title": "Personal communication with Doctor X" } ``` -All references provided in `manual-references.json` must provide values for the `type` and `standard_citation` fields. +All manual references must provide values for the "id" and "type" fields. For guidance on what CSL JSON should be like for different document types, refer to [these examples](https://github.com/aurimasv/zotero-import-export-formats/blob/a51c342e66bebd97b73a7230047b801c8f7bb690/CSL%20JSON.json). +Manubot offers some support for other bibliographic metadata formats besides CSL JSON, by delegating conversion to the `pandoc-citeproc --bib2json` [utility](https://github.com/jgm/pandoc-citeproc/blob/master/man/pandoc-citeproc.1.md#convert-mode). +Formats are inferred from filename extensions. +So, for example, to provide metadata for `@url:https://github.com/manubot/rootstock` in BibTeX format, create the file `content/manual-references.bib` and create an item whose definition starts with the excerpt: + +```latex +@misc{url:https://github.com/manubot/rootstock, +``` + +Processed reference metadata in CSL JSON format, either generated by Manubot or specified via manual references, is exported to `references.json`. +This file is located in the `output` branch on GitHub or in the `output` subdirectory of local builds. +The "id" field in `references.json` and in the final manuscript uses a shortened ID that is derived from the original ID. +For debugging information, see `citations.tsv`, which shows citation identifiers as they progress through the processing pipeline. +In order to freeze all references, rather than have Manubot regenerate them during future builds, copy the `references.json` output file to `content` with a filename matching the `manual-references*.json` pattern. +One tip is to embed the date `references.json` was generated into the frozen manual reference filename, like `content/manual-references-2019-06-21.json`. + ## Manuscript metadata [`content/metadata.yaml`](content/metadata.yaml) contains manuscript metadata that gets passed through to Pandoc, via a [`yaml_metadata_block`](https://pandoc.org/MANUAL.html#extension-yaml_metadata_block). @@ -168,39 +188,30 @@ funders: GBMF4552 # optional Note that `affiliations` should be a list to allow for multiple affiliations per author. -## Manubot feedback +## Custom formatting -If you experience any issues with the Manubot or would like to contribute to its source code, please visit [`manubot/manubot`](https://github.com/manubot/manubot) or [`manubot/rootstock`](https://github.com/manubot/rootstock). - -## Examples +Modifying the manuscript formatting requires modifying the CSS in the file [`build/themes/default.html`](build/themes/default.html). +Common formatting changes, such as [font size](https://github.com/manubot/rootstock/issues/239) and [double spacing](https://github.com/manubot/rootstock/issues/244), can be found by searching the [Rootstock issues](https://github.com/manubot/rootstock/issues). +Open a [new issue](https://github.com/manubot/rootstock/issues/new) if you have a new formatting question. -For additional examples, check out existing manuscripts that use the Manubot (some of which are still in progress): +Changing the citation style or which interactive HTML plugins are loaded requires editing the build script [`build/build.sh`](build/build.sh). +The citation style is determined by the Citation Style Language file specified by `CSL_PATH`. +It can be changed to use other existing styles as [described here](https://github.com/manubot/rootstock/issues/242#issuecomment-507688339). -+ Satoshi Nakamoto's Bitcoin Whitepaper ([source](https://github.com/dhimmel/bitcoin-whitepaper/), [manuscript](https://dhimmel.github.io/bitcoin-whitepaper/), [commentary](https://steemit.com/manubot/@dhimmel/how-i-used-the-manubot-to-reproduce-the-bitcoin-whitepaper)) -+ The Sci-Hub Coverage Study ([source](https://github.com/greenelab/scihub-manuscript), [manuscript](https://greenelab.github.io/scihub-manuscript/)) -+ The GimmeMotifs manscript on transcription factor motif analysis ([source](https://github.com/simonvh/gimmemotifs-manuscript), [manuscript](https://simonvh.github.io/gimmemotifs-manuscript/manuscript.pdf)) -+ A Report for the Vagelos Scholars Program by Michael Zietz ([source](https://github.com/zietzm/Vagelos2017), [manuscript](https://zietzm.github.io/Vagelos2017/)) -+ The Deep Review ([source](https://github.com/greenelab/deep-review), [manuscript](https://greenelab.github.io/deep-review/)) -+ Ten Quick Tips for Deep Learning ([source](https://github.com/Benjamin-Lee/deep-rules), [manuscript](https://benjamin-lee.github.io/deep-rules/)) -+ The Meta Review ([source](https://github.com/greenelab/meta-review), [manuscript](https://greenelab.github.io/meta-review/)) -+ A review of Network Methods for Multiomic Data Integration ([source](https://github.com/zietzm/integration-review), [manuscript](https://zietzm.github.io/integration-review/)) -+ The Project Rephetio Manuscript ([source](https://github.com/dhimmel/rephetio-manuscript/), [manuscript](https://dhimmel.github.io/rephetio-manuscript/)) -+ A Literature Review for Project Planning by David Slochower ([source](https://github.com/slochower/synthetic-motor-literature), [manuscript](https://slochower.github.io/synthetic-motor-literature/)) -+ The TFSEE Manuscript by Venkat Malladi et al. ([source](https://github.com/vsmalladi/tfsee-manuscript), [manuscript](https://vsmalladi.github.io/tfsee-manuscript/)) -+ Creating a Global Emissions Timeseries dataset by Robert Gieseke et al. ([source](https://github.com/openclimatedata/global-emissions), [manuscript](https://openclimatedata.github.io/global-emissions/)) -+ The yt 3.0 methods paper ([source](https://github.com/yt-project/yt-3.0-paper), [manuscript](https://yt-project.github.io/yt-3.0-paper/)) -+ The TPOT-DS Manuscript (includes Hypothesis annotations, [source](https://github.com/trang1618/tpot-ds-ms), [manuscript](https://trang1618.github.io/tpot-ds-ms/)) -+ The Manubot 2018 Development Proposal ([source](https://github.com/greenelab/manufund-2018), [manuscript](https://greenelab.github.io/manufund-2018/)) +## Manubot feedback -If you are using the Manubot, feel free to submit a pull request to add your manuscript to the list above. +If you experience any issues with the Manubot or would like to contribute to its source code, please visit [`manubot/manubot`](https://github.com/manubot/manubot) or [`manubot/rootstock`](https://github.com/manubot/rootstock). ## Citing Manubot -To cite the Manubot project or for more information on its design and history, see `@url:https://greenelab.github.io/meta-review/`: +To cite the Manubot project or for more information on its design and history, see `@doi:10.1371/journal.pcbi.1007128`: > **Open collaborative writing with Manubot**
Daniel S. Himmelstein, Vincent Rubinetti, David R. Slochower, Dongbo Hu, Venkat S. Malladi, Casey S. Greene, Anthony Gitter
-_Manubot Preprint_ (2019) +*PLOS Computational Biology* (2019-06-24)
+DOI: [10.1371/journal.pcbi.1007128](https://doi.org/10.1371/journal.pcbi.1007128) ยท PMID: [31233491](https://www.ncbi.nlm.nih.gov/pubmed/31233491) + +The Manubot version of this manuscript is available at . ## Acknowledgments diff --git a/build/README.md b/build/README.md index 3be7e944..1a886f1d 100644 --- a/build/README.md +++ b/build/README.md @@ -4,10 +4,10 @@ `sh build/build.sh` should be executed from the root directory of the repository. By default, `build.sh` creates HTML and PDF outputs. However, setting the `BUILD_PDF` environment variable to `false` will suppress PDF output. -For example, run local builds using the command `BUILD_PDF=false sh build/build.sh`. +For example, run local builds using the command `BUILD_PDF=false bash build/build.sh`. To build a DOCX file of the manuscript, set the `BUILD_DOCX` environment variable to `true`. -For example, use the command `BUILD_DOCX=true sh build/build.sh`. +For example, use the command `BUILD_DOCX=true bash build/build.sh`. To export DOCX for all Travis builds, set a [Travis environment variable](https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings). Currently, equation numbers via `pandoc-eqnos` are not supported for DOCX output. There is varying support for embedding images in DOCX output. @@ -17,7 +17,7 @@ Please reference [Pull Request #40](https://github.com/manubot/rootstock/pull/40 Note: currently, **Windows is not supported**. -Install or update the [conda](https://conda.io) environment specified in [`environment.yml`](environment.yml) by running: +Install or update the [conda](https://conda.io) environment specified in [`environment.yml`](environment.yml) by running the following commands from this directory: ```sh # If the manubot environment already exists, remove it first @@ -30,3 +30,19 @@ conda env create --file environment.yml Activate with `conda activate manubot` (assumes `conda` version of [at least](https://github.com/conda/conda/blob/9d759d8edeb86569c25f6eb82053f09581013a2a/CHANGELOG.md#440-2017-12-20) 4.4). The environment should successfully install on both Linux and macOS. However, it will fail on Windows due to the [`pango`](https://anaconda.org/conda-forge/pango) dependency. + +Because the build process is dependent on having the appropriate version of the `manubot` Python package, it is necessary to use the version specified in `environment.yml`. +The latest `manubot` release on PyPI may not be compatible with the latest version of this rootstock repository. + +## Building PDFs + +If Docker is available, `build.sh` uses the [Athena](https://www.athenapdf.com/) [Docker image](https://hub.docker.com/r/arachnysdocker/athenapdf) to build the PDF. +Otherwise, `build.sh` uses [WeasyPrint](https://weasyprint.org/) to build the PDF. +It is common for WeasyPrint to generate many warnings and errors that can be safely ignored. +Examples are shown below: +``` +WARNING: Ignored `pointer-events: none` at 3:16, unknown property. +WARNING: Ignored `font-display:auto` at 1:53114, descriptor not supported. +ERROR: Failed to load font at "https://use.fontawesome.com/releases/v5.7.2/webfonts/fa-brands-400.eot#iefix" +WARNING: Expected a media type, got only/**/screen +``` diff --git a/build/autobuild.sh b/build/autobuild.sh old mode 100644 new mode 100755 index d6a53130..e82dbfb6 --- a/build/autobuild.sh +++ b/build/autobuild.sh @@ -1,6 +1,9 @@ -# Automatically rebuild mansucript outputs and the webpage when content changes -# Depends on watchdog https://github.com/gorakhargosh/watchdog +#!/usr/bin/env bash + +## autobuild.sh: automatically rebuild mansucript outputs and the webpage when content changes +## Depends on watchdog https://github.com/gorakhargosh/watchdog + watchmedo shell-command \ --wait \ - --command='sh build/build.sh && python build/webpage.py' \ + --command='bash build/build.sh && python build/webpage.py' \ content diff --git a/build/build.sh b/build/build.sh old mode 100644 new mode 100755 index 4f0ff06f..eec2bd87 --- a/build/build.sh +++ b/build/build.sh @@ -1,4 +1,10 @@ -set -o errexit +#!/usr/bin/env bash + +## build.sh: compile manuscript outputs from content using Manubot and Pandoc + +set -o errexit \ + -o nounset \ + -o pipefail # Set timezone used by Python for setting the manuscript's date export TZ=Etc/UTC @@ -6,7 +12,7 @@ export TZ=Etc/UTC export LC_ALL=en_US.UTF-8 # Generate reference information -echo "Retrieving and processing reference metadata" +echo >&2 "Retrieving and processing reference metadata" manubot process \ --content-directory=content \ --output-directory=output \ @@ -23,15 +29,15 @@ mkdir -p output # Create HTML output # http://pandoc.org/MANUAL.html -echo "Exporting HTML manuscript" +echo >&2 "Exporting HTML manuscript" pandoc --verbose \ --from=markdown \ --to=html5 \ --filter=pandoc-fignos \ --filter=pandoc-eqnos \ --filter=pandoc-tablenos \ - --bibliography=$BIBLIOGRAPHY_PATH \ - --csl=$CSL_PATH \ + --bibliography="$BIBLIOGRAPHY_PATH" \ + --csl="$CSL_PATH" \ --metadata link-citations=true \ --include-after-body=build/themes/default.html \ --include-after-body=build/plugins/table-scroll.html \ @@ -48,14 +54,14 @@ pandoc --verbose \ --include-after-body=build/plugins/hypothesis.html \ --include-after-body=build/plugins/analytics.html \ --output=output/manuscript.html \ - $INPUT_PATH + "$INPUT_PATH" # Return null if docker command is missing, otherwise return path to docker -DOCKER_EXISTS=`command -v docker` +DOCKER_EXISTS="$(command -v docker || true)" # Create PDF output (unless BUILD_PDF environment variable equals "false") -if [ "$BUILD_PDF" != "false" ] && [ -z "$DOCKER_EXISTS" ]; then - echo "Exporting PDF manuscript using WeasyPrint" +if [ "${BUILD_PDF:-}" != "false" ] && [ -z "$DOCKER_EXISTS" ]; then + echo >&2 "Exporting PDF manuscript using WeasyPrint" if [ -L images ]; then rm images; fi # if images is a symlink, remove it ln -s content/images pandoc \ @@ -66,25 +72,25 @@ if [ "$BUILD_PDF" != "false" ] && [ -z "$DOCKER_EXISTS" ]; then --filter=pandoc-fignos \ --filter=pandoc-eqnos \ --filter=pandoc-tablenos \ - --bibliography=$BIBLIOGRAPHY_PATH \ - --csl=$CSL_PATH \ + --bibliography="$BIBLIOGRAPHY_PATH" \ + --csl="$CSL_PATH" \ --metadata link-citations=true \ --webtex=https://latex.codecogs.com/svg.latex? \ --include-after-body=build/themes/default.html \ --output=output/manuscript.pdf \ - $INPUT_PATH + "$INPUT_PATH" rm images fi # Create PDF output (unless BUILD_PDF environment variable equals "false") -if [ "$BUILD_PDF" != "false" ] && [ -n "$DOCKER_EXISTS" ]; then - echo "Exporting PDF manuscript using Docker + Athena" +if [ "${BUILD_PDF:-}" != "false" ] && [ -n "$DOCKER_EXISTS" ]; then + echo >&2 "Exporting PDF manuscript using Docker + Athena" if [ -d output/images ]; then rm -rf output/images; fi # if images is a directory, remove it cp -R -L content/images output/ docker run \ --rm \ --shm-size=1g \ - --volume=`pwd`/output:/converted/ \ + --volume="$(pwd)/output:/converted/" \ --security-opt=seccomp:unconfined \ arachnysdocker/athenapdf:2.16.0 \ athenapdf \ @@ -94,21 +100,21 @@ if [ "$BUILD_PDF" != "false" ] && [ -n "$DOCKER_EXISTS" ]; then fi # Create DOCX output (if BUILD_DOCX environment variable equals "true") -if [ "$BUILD_DOCX" = "true" ]; then - echo "Exporting Word Docx manuscript" +if [ "${BUILD_DOCX:-}" = "true" ]; then + echo >&2 "Exporting Word Docx manuscript" pandoc --verbose \ --from=markdown \ --to=docx \ --filter=pandoc-fignos \ --filter=pandoc-eqnos \ --filter=pandoc-tablenos \ - --bibliography=$BIBLIOGRAPHY_PATH \ - --csl=$CSL_PATH \ + --bibliography="$BIBLIOGRAPHY_PATH" \ + --csl="$CSL_PATH" \ --metadata link-citations=true \ --reference-doc=build/themes/default.docx \ --resource-path=.:content \ --output=output/manuscript.docx \ - $INPUT_PATH + "$INPUT_PATH" fi -echo "Build complete" +echo >&2 "Build complete" diff --git a/build/environment.yml b/build/environment.yml index 553a5dbb..fa807dba 100644 --- a/build/environment.yml +++ b/build/environment.yml @@ -2,32 +2,33 @@ name: manubot channels: - conda-forge dependencies: - - conda-forge::cairo=1.14.12 - - conda-forge::cairocffi=0.8.0 - - conda-forge::cffi=1.11.5 - - conda-forge::ghp-import=0.5.5 - - conda-forge::jinja2=2.10 - - conda-forge::jsonschema=2.6.0 - - conda-forge::pandas=0.24.0 - - conda-forge::pandoc=2.6 - - conda-forge::pango=1.40.14 - - conda-forge::psutil=5.5.1 - - conda-forge::python=3.6.7 - - conda-forge::pyyaml=3.13 - - conda-forge::requests=2.21.0 - - conda-forge::watchdog=0.8.3 + - cairo=1.14.12 + - cairocffi=0.8.0 + - cffi=1.12.3 + - ghp-import=0.5.5 + - jinja2=2.10 + - jsonschema=3.0.1 + - pandas=0.24.2 + - pandoc=2.7.2 + - pango=1.40.14 + - pip=19.1 + - psutil=5.6.2 + - python=3.6.7 + - pyyaml=5.1 + - requests=2.22.0 + - watchdog=0.8.3 - pip: - errorhandler==2.0.1 - - git+https://github.com/manubot/manubot@4505db3fd8a9dc1ba26c36f3fea9accbf02d47d8 + - git+https://github.com/manubot/manubot@2a99f4af4a352d2e082988d364e01e2e2809a87b - jsonref==0.2 - opentimestamps-client==0.6.0 - opentimestamps==0.3.0 - - pandoc-eqnos==1.3.0 - - pandoc-fignos==1.3.0 - - pandoc-tablenos==1.3.0 - - pandoc-xnos==1.1.1 + - pandoc-eqnos==1.4.3 + - pandoc-fignos==1.4.2 + - pandoc-tablenos==1.4.2 + - pandoc-xnos==1.2.0 - pybase62==0.4.0 - pysha3==1.0.2 - python-bitcoinlib==0.9.0 - - requests-cache==0.4.13 + - requests-cache==0.5.0 - weasyprint==0.42.3 diff --git a/ci/.gitignore b/ci/.gitignore index 5923dee3..f50cd000 100644 --- a/ci/.gitignore +++ b/ci/.gitignore @@ -1,5 +1,5 @@ -# SSH private key -deploy.key +# SSH public and private keys +deploy.key* -# Output from travis encrypt-file +# Output from travis encrypt-file (legacy) travis-encrypt-file.log diff --git a/ci/README.md b/ci/README.md index eb4c138d..1c34f3a7 100644 --- a/ci/README.md +++ b/ci/README.md @@ -1,29 +1,8 @@ -# Continuous integration / analysis directory +# Continuous integration tools -[![Build Status](https://travis-ci.org/Benjamin-Lee/deep-rules.svg?branch=master)](https://travis-ci.org/Benjamin-Lee/deep-rules) +This directory contains tools and files for continuous integration (CI). +Specifically, [`deploy.sh`](deploy.sh) runs on successful `master` branch builds that are not pull requests. +The contents of `../webpage` are committed to the `gh-pages` branch. +The contents of `../output` are committed to the `output` branch. -This repository uses [continuous analysis](https://doi.org/10.1101/056473 "Reproducible Computational Workflows with Continuous Analysis") to create the manuscript and commit it back to GitHub. -[`deploy.sh`](deploy.sh) runs on successful `master` branch builds that are not pull requests. -The contents of `/output` are committed to the `gh-pages` branch. -The contents of `/references/generated` are committed to the `references` branch. - -## Generating the GitHub deploy key - -To generate and configure the GitHub SSH deploy key, run the following commands from this directory. - -```sh -# Generate a new SSH key -ssh-keygen \ - -t rsa \ - -b 4096 \ - -C "travis@travis-ci.com" \ - -N "" \ - -f deploy.key -# Add deploy.key.pub to GitHub under the repository's settings -# see https://developer.github.com/guides/managing-deploy-keys/#deploy-keys - -# Encrypt and upload key to Travis CI. -# See https://docs.travis-ci.com/user/encrypting-files/ -travis encrypt-file deploy.key -# Modify the returned command to decrypt the key in ci/deploy.sh -``` +For more information on the CI implementation, see the [Travis CI configuration](../.travis.yml) and the CI setup documentation in `SETUP.md`. \ No newline at end of file diff --git a/ci/deploy.sh b/ci/deploy.sh index 066337f0..f7ba215c 100644 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -1,28 +1,44 @@ -# Exit on errors -set -o errexit +#!/usr/bin/env bash + +## deploy.sh: run during a Travis CI build to deploy manuscript outputs to the output and gh-pages branches on GitHub. + +# Set options for extra caution & debugging +set -o errexit \ + -o nounset \ + -o pipefail # Add commit hash to the README -export OWNER_NAME=`dirname $TRAVIS_REPO_SLUG` -export REPO_NAME=`basename $TRAVIS_REPO_SLUG` +OWNER_NAME="$(dirname "$TRAVIS_REPO_SLUG")" +REPO_NAME="$(basename "$TRAVIS_REPO_SLUG")" +export OWNER_NAME REPO_NAME envsubst < webpage/README.md > webpage/README-complete.md mv webpage/README-complete.md webpage/README.md # Configure git git config --global push.default simple -git config --global user.email `git log --max-count=1 --format='%ae'` -git config --global user.name "`git log --max-count=1 --format='%an'`" -git checkout $TRAVIS_BRANCH -git remote set-url origin git@github.com:$TRAVIS_REPO_SLUG.git +git config --global user.email "$(git log --max-count=1 --format='%ae')" +git config --global user.name "$(git log --max-count=1 --format='%an')" +git checkout "$TRAVIS_BRANCH" +git remote set-url origin "git@github.com:$TRAVIS_REPO_SLUG.git" # Decrypt and add SSH key +eval "$(ssh-agent -s)" +( +set +o xtrace # disable xtrace in subshell for private key operations +if [ -v MANUBOT_SSH_PRIVATE_KEY ]; then + base64 --decode <<< "$MANUBOT_SSH_PRIVATE_KEY" | ssh-add - +else +echo "DeprecationWarning: Loading deploy.key from an encrypted file. +In the future, using the MANUBOT_SSH_PRIVATE_KEY environment variable may be required." openssl aes-256-cbc \ -K $encrypted_cdc27f6ebb6e_key \ -iv $encrypted_cdc27f6ebb6e_iv \ -in ci/deploy.key.enc \ -out ci/deploy.key -d -eval `ssh-agent -s` chmod 600 ci/deploy.key ssh-add ci/deploy.key +fi +) # Fetch and create gh-pages and output branches # Travis does a shallow and single branch git clone @@ -33,24 +49,24 @@ git fetch origin gh-pages:gh-pages output:output python build/webpage.py \ --no-ots-cache \ --checkout=gh-pages \ - --version=$TRAVIS_COMMIT + --version="$TRAVIS_COMMIT" # Generate OpenTimestamps -ots stamp webpage/v/$TRAVIS_COMMIT/index.html -if [ "$BUILD_PDF" != "false" ]; then - ots stamp webpage/v/$TRAVIS_COMMIT/manuscript.pdf +ots stamp "webpage/v/$TRAVIS_COMMIT/index.html" +if [ "${BUILD_PDF:-}" != "false" ]; then + ots stamp "webpage/v/$TRAVIS_COMMIT/manuscript.pdf" fi # Commit message MESSAGE="\ -`git log --max-count=1 --format='%s'` +$(git log --max-count=1 --format='%s') This build is based on https://github.com/$TRAVIS_REPO_SLUG/commit/$TRAVIS_COMMIT. This commit was created by the following Travis CI build and job: -https://travis-ci.org/$TRAVIS_REPO_SLUG/builds/$TRAVIS_BUILD_ID -https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID +$TRAVIS_BUILD_WEB_URL +$TRAVIS_JOB_WEB_URL [ci skip] diff --git a/content/manual-references.json b/content/manual-references.json index 8852b750..c1daca28 100644 --- a/content/manual-references.json +++ b/content/manual-references.json @@ -1,7 +1,7 @@ [ { + "id": "url:https://github.com/manubot/rootstock", "type": "webpage", - "standard_citation": "url:https://github.com/manubot/rootstock", "URL": "https://github.com/manubot/rootstock", "title": "manubot/rootstock GitHub repository", "container-title": "GitHub",