Skip to content

Multiple Python versions as a comma-separated list #870

@paduszyk

Description

@paduszyk

Thanks for maintaining the project and considering my idea 🙂

Description:
Allowing the action to accept comma-separated lists of Python versions would enhance the user experience if the versions are passed dynamically, as an output from another job.

Justification:
Assume I would like to define multiple Python versions dynamically, e.g., by using a script get_python_versions.py that parses the pyproject.toml file (let us say, from classifiers or requires-python). The script prints the \n-separated list of strings to terminal:

$ python get_python_versions.py
3.9
3.10
3.11
3.12

Then I would like to use the script's output in the action. Since the action accepts newline-separated lists only, I have to do the following:

jobs:
  python-versions:
    runs-on: ubuntu-latest
    outputs:
      python-versions: ${{ steps.python-versions.outputs.python-versions }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
      - id: python-versions
        run: |
          echo "python-versions<<EOF" >> $GITHUB_OUTPUT
          echo "$(python get_python_versions.py)" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT
  build:
    needs:
      - python-versions
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ needs.python-versions.outputs.python-versions }}

This works nicely. But... Now assume that the script returns a comma-separated list:

$ python get_python_versions.py
3.9,3.10,3.11,3.12

If comma-separated lists were allowed as the action's input, the python-versions step would be more concise and less verbose:

      ...
      - id: python-versions
        run: |
          echo "python-versions=$(python get_python_versions.py)" >> $GITHUB_OUTPUT
      ...

Are you willing to submit a PR?

I'm not familiar with Node/JS, so I'm not sure whether I am capable of opening a PR.

Metadata

Metadata

Labels

feature requestNew feature or request to improve the current logic

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions