Skip to content

Parse asdf.sh tool-versions file to reuse version information in GitHub Actions

License

Notifications You must be signed in to change notification settings

endorama/asdf-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

typescript-action status

asdf-parse-tool-versions

Parses asdf .tool-versions file extracting version information.

Returns a JSON string as output with this format:

{"golang":"1.12.5","ruby":"2.7.0"}

Each tool has it's own key where value is the value in the .tool-versions file.

The action also exports all versions as environment variables with the format <tool>_VERSION (i.e. GOLANG_VERSION).

Usage

---
name: run on master

on:
  push:
    branches:
      - main

jobs:
  nightly:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: gather versions
        uses: endorama/asdf-parse-tool-versions@v1
        id: versions

      - name: install Go
        uses: actions/setup-go@v1
        with: 
          go-version: "${{ env.GOLANG_VERSION }}"

      # OR using action output
      - name: install Go
        uses: actions/setup-go@v1
        with: 
          go-version: ${{ fromJSON(steps.versions.outputs.tools).golang }}

      # ...