Skip to content

A GitHub action to turn .tool-versions' content into environment variables

License

Notifications You must be signed in to change notification settings

paulo-ferraz-oliveira/parse-tool-versions

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

parse-tool-versions

MacOS Ubuntu Windows

This GitHub action parses a .tool-versions file (as specified by asdf), found at the root folder of your GitHub repository, reads the versions declared therein and makes them available as step outputs variables.

Usage

Include, in your GitHub actions' workflows,

      - uses: paulo-ferraz-oliveira/parse-tool-versions@v1
        id: tool-versions

to set the outputs to use in subsequent steps.

Note: it would be easier to have these accessible from the environment but due to a security restriction Node.js -updated environment variables are not available from one step to the other.

Check our examples below.

Example .github/workflows/ci.yml

---
"on": push

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: paulo-ferraz-oliveira/parse-tool-versions@v1
        id: tool-versions
      - run: echo ${{steps.tool-versions.outputs.ruby}} # 2.5.3
      - run: echo ${{steps.tool-versions.outputs.npm}} # 8.3.1
      - run: echo ${{steps.tool-versions.outputs.python}} # 3.7.2

Example .tool-versions

ruby 2.5.3 # This is a comment
# This is another comment
npm 8.3.1
python 3.7.2 2.7.15 system # Only 3.7.2 used

Target platforms

It is our intent that the action runs on all GitHub action environments that support asdf: at the moment of this writing, ubuntu-latest, windows-latest, and macos-latest (as well as their versioned variants).

Open a bug report if that's not the case.

Versioning

This project adheres to Semantic Versioning.

Readme

We get inspiration for our README's format/content from Make a README.

Changelog

See the Releases page.

Contributing

Check CONTRIBUTING.

License

Check LICENSE.

About

A GitHub action to turn .tool-versions' content into environment variables

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks