Skip to content

Instantly share code, notes, and snippets.

@userdocs
Last active March 11, 2023 14:48
Show Gist options
  • Save userdocs/9a205961d49420d1d48f943e921c99b8 to your computer and use it in GitHub Desktop.
Save userdocs/9a205961d49420d1d48f943e921c99b8 to your computer and use it in GitHub Desktop.
pandoc - easy install - linux - github actions and workflows

Pandoc is a simple multi binary setup.

🟦 It does not really require a complicated action or a docker container to quickly bootstrap this on linux or when using it in a github action.

We will bootstrap these binaries with two commands.

pandoc
pandoc-lua
pandoc-server

Get the latest github tag and set it to the variable pandoc_git_tag

pandoc_git_tag="$(git ls-remote -q -t --refs https://github.com/jgm/pandoc.git | awk '/tags\/[0-9]/{sub("refs/tags/", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"

Download and auto extract the binary to a location of your choosing. In this example we use $(pwd)

# with curl
curl -sLo- "https://github.com/jgm/pandoc/releases/latest/download/pandoc-${pandoc_git_tag}-linux-amd64.tar.gz" | tar xzf - --strip-components 2 -C "$(pwd)" --exclude="share"

# with wget
wget -q -O- "https://github.com/jgm/pandoc/releases/latest/download/pandoc-${pandoc_git_tag}-linux-amd64.tar.gz" | tar xzf - --strip-components 2 -C "$(pwd)" --exclude="share"

Check the version.

./pandoc --version

In a github workflow

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Pandoc - Bootstrap
        run: |
          pandoc_git_tag="$(git ls-remote -q -t --refs https://github.com/jgm/pandoc.git | awk '/tags\/[0-9]/{sub("refs/tags/", ""); print $2 }' | awk '!/^$/' | sort -rV | head -n 1)"
          curl -sLo- "https://github.com/jgm/pandoc/releases/latest/download/pandoc-${pandoc_git_tag}-linux-amd64.tar.gz" | tar xzf - --strip-components 2 -C "$(pwd)" --exclude="share"
          
      - name: Pandoc - version
        run: ./pandoc --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment