From daab49b0c288d9975f3e2a7f913caa7dc267fa89 Mon Sep 17 00:00:00 2001 From: Tate Date: Wed, 13 Apr 2022 14:36:27 -0600 Subject: [PATCH] Add docs, github badge, and have script fail on error --- README.md | 57 +++++++++++++++++++++++++++++++++++----- bin/tool-versions-to-env | 6 +++-- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 696e612..cefb61d 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,61 @@ -# This action sets .tool-versions as variables for other actions to use in the format of - _version=version_number +# tool-versions-to-env +![GitHub Actions Status](https://github.com/smartcontractkit/tool-versions-to-env-action/workflows/test%20asdf%20plugin/badge.svg?branch=main) -## Inputs -## `path_to_tool_versions` +Is a tool to convert the variables in an asdf .tool-versions file into usable environment variables. It can grab a single variable to be used inline. It can dump the variables out to a .env file. It can dump the variables into a github action output. It outputs each library and version in the form of _version= for example the library in the .tool-versions file `golang 1.18` will be converted to the equivalent environment variable `golang_version=1.18`. + +This is useful when you want to hold versions for certain tools and libraries in one place but use the contained version elsewhere. + +# This repo contains: +- tool-versions-to-env shell script to convert .tool-versions into environment variables +- The github action workflow to use this tool in a github action +- The asdf plugin scripts to add the tool using asdf. + +## Docs for the tool itself + Requires at least 1 argument + Argument #1: Action options + 1 = print to .env file + Argument #2: Optional. The path to the .tool-versions file + Argument #3: Optional. The path to the .env file to create + 2 = sent to github action output + Argument #2: Optional. The path to the .tool-versions file + 3 = only print given variable to stdout + Argument #2: Required. The tool version to output to stdout + Argument #3: Optional. The path to the .tool-versions file + + Example for 1 or 2: tool-versions-to-env 1 + Example for 3: tool-versions-to-env 3 golang + +## Docs for the Action +### This action sets .tool-versions as variables for other actions to use in the format of + _version= + +### Inputs + +### `path_to_tool_versions` **Required** The path to the .tool-versions file to read -## Outputs +### Outputs The variables in provided .tool-versions file as variables in the form of _version, example: golang_version -## Example usage +### Example usage -uses: smartcontractkit/tool-versions-to-env@v1 +uses: smartcontractkit/tool-versions-to-env@v1.0.7 with: path_to_tool_versions: "./.tool-versions" + +# Docs for the asdf plugin + +[tool-versions-to-env](https://github.com/smartcontractkit/tool-versions-to-env-action) plugin for [asdf](https://github.com/asdf-vm/asdf) version manager. + +## Install + +```shell +asdf plugin add tool-versions-to-env https://github.com/smartcontractkit/tool-versions-to-env-action.git +``` + +## Usage + +Check [asdf](https://github.com/asdf-vm/asdf) readme for instructions on how to install & manage versions of helmenv. diff --git a/bin/tool-versions-to-env b/bin/tool-versions-to-env index 2e2a55b..2adc226 100755 --- a/bin/tool-versions-to-env +++ b/bin/tool-versions-to-env @@ -1,7 +1,9 @@ #!/usr/bin/env bash +set -e + # Script to read .tool-versions library versions into environment variables -# in the form of library_name_version=version_number +# in the form of _version= # Create the functions @@ -99,5 +101,5 @@ elif [ "$ACTION_OPTION" -eq 3 ]; then # print single to variable to stdout read_tool_versions_write_to_env 3 "$TOOL_VERSIONS_FILE" "" 0 else - echo "First arument was not of option 1, 2, or 3" + echo "First argument was not of option 1, 2, or 3" fi