Merge pull request #142 from NIFU-NO/dev #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Setup Quarto' | |
author: 'Christophe Dervieux' | |
description: 'This action will setup Quarto from the git repository https://github.com/quarto-dev/quarto-cli/' | |
inputs: | |
version: | |
description: 'The version of Quarto to use. Either a release tag without "v" prefix (e.g., "0.9.486"), "pre-release" for latest built dev version, or "release", for the latest stable version.' | |
required: false | |
default: 'release' | |
tinytex: | |
description: 'If true, install TinyTex, required for PDF rendering' | |
required: false | |
default: 'false' | |
outputs: | |
version: | |
description: 'The installed version of quarto.' | |
runs: | |
using: 'composite' | |
steps: | |
- name: 'Choose which binary to use' | |
run: | | |
# Select correct bundle for OS type | |
case $RUNNER_OS in | |
"Linux") | |
echo "BUNDLE_EXT=linux-amd64.deb" >> $GITHUB_ENV | |
;; | |
"macOS") | |
echo "BUNDLE_EXT=macos.pkg" >> $GITHUB_ENV | |
;; | |
"Windows") | |
echo "BUNDLE_EXT=win.msi" >> $GITHUB_ENV | |
;; | |
*) | |
echo "$RUNNER_OS not supported" | |
exit 1 | |
;; | |
esac | |
shell: bash | |
working-directory: ${{ runner.temp }} | |
- name: 'Download Quarto' | |
id: download-quarto | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
if [ ${{ runner.os }} != "Windows" ]; then | |
# On Windows scoop will be used so no need to download the release | |
if [ "${{inputs.version}}" == "release" ]; then | |
# download the latest stable release | |
gh release download --repo github.com/quarto-dev/quarto-cli --pattern ${{ format('*{0}', env.BUNDLE_EXT) }} | |
version=$(curl https://quarto.org/docs/download/_download.json | jq -r '.version') | |
echo "version=${version}" >> $GITHUB_OUTPUT | |
elif [ "${{inputs.version}}" == "LATEST" -o "${{inputs.version}}" == "pre-release" ]; then | |
# get latest pre release version | |
version=$(curl https://quarto.org/docs/download/_prerelease.json | jq -r '.version') | |
wget https://github.com/quarto-dev/quarto-cli/releases/download/v$version/quarto-$version-${{env.BUNDLE_EXT}} | |
echo "version=${version}" >> $GITHUB_OUTPUT | |
else | |
# download a specific release | |
wget https://github.com/quarto-dev/quarto-cli/releases/download/v${{inputs.version}}/quarto-${{inputs.version}}-${{env.BUNDLE_EXT}} | |
echo "version=${{inputs.version}}" >> $GITHUB_OUTPUT | |
fi | |
echo "installer=$(ls quarto*${{ env.BUNDLE_EXT }})" >> $GITHUB_OUTPUT | |
else | |
: # do nothing for now (https://github.com/quarto-dev/quarto-actions/issues/59 :facepalm:) | |
# FIXME: how to get version information from scoop in windows runners? | |
# send the cderv bat-signal! | |
fi | |
shell: bash | |
working-directory: ${{ runner.temp }} | |
- name: 'Install Quarto' | |
run: | | |
# Install quarto | |
[ ${{ runner.os }} != "Windows" ] && installer=${{ steps.download-quarto.outputs.installer }} | |
case $RUNNER_OS in | |
"Linux") | |
sudo apt install ./$installer | |
;; | |
"macOS") | |
sudo installer -pkg ./$installer -target '/' | |
;; | |
"Windows") | |
# can't install msi for now so use scoop | |
if [ "${{inputs.version}}" == "release" ] | |
then | |
powershell -File $GITHUB_ACTION_PATH/install-quarto-windows.ps1 | |
else | |
powershell -File $GITHUB_ACTION_PATH/install-quarto-windows.ps1 ${{ inputs.version }} | |
fi | |
;; | |
*) | |
echo "$RUNNER_OS not supported" | |
exit 1 | |
;; | |
esac | |
[ ${{ runner.os }} != "Windows" ] && rm $installer | |
echo "Quarto Installed !" | |
shell: bash | |
working-directory: ${{ runner.temp }} | |
- name: 'Install TinyTeX' | |
env: | |
QUARTO_PRINT_STACK: true | |
if: ${{ inputs.tinytex == 'true'}} | |
run: | | |
quarto install tool tinytex --no-prompt --log-level warning | |
case $RUNNER_OS in | |
"Linux") | |
echo "$HOME/bin" >> $GITHUB_PATH | |
;; | |
"macOS") | |
echo "$(dirname $(find ~/Library/TinyTeX -name tlmgr))" >> $GITHUB_PATH | |
;; | |
"Windows") | |
echo "$(dirname $(find $APPDATA/TinyTeX -name tlmgr.bat))" >> $GITHUB_PATH | |
;; | |
*) | |
echo "$RUNNER_OS not supported" | |
exit 1 | |
;; | |
esac | |
echo "TinyTeX installed !" | |
shell: bash | |
working-directory: ${{ runner.temp }} |