Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
tag

GitHub Action

Latest Python Versions

v1.1.0

Latest Python Versions

tag

Latest Python Versions

Get latest Python versions to run in a matrix

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Latest Python Versions

uses: snok/[email protected]

Learn more about this action in snok/latest-python-versions

Choose a version

release tests

Latest Python Versions

This action will fetch up-to-date data on the latest Python versions available on Github Actions.

If you're already running tests on multiple Python versions, this action will allow you to replace your static matrix definitions with dynamic ones. With a dynamic version matrix definition, you will for example always be on the latest pre-release of the next upcoming Python release.

The Python versions are fetched from here - the official Github action version manifest.

Usage

To use the action, simply throw this into one of your workflows

- uses: snok/latest-python-versions@v1
  id: get-python-versions
  with:
    min-version: 3.7
    max-version: 3.10  # not required - defaults to latest
    include-prereleases: true  # not required - defaults to false

The action produces an output that can be accessed using:

${{ steps.get-python-versions.outputs.latest-python-versions }}

See examples below for recommended usage.

Example

name: Test

on: pull_request

jobs:
  linting:
    ...

  # Define the job to run before your matrix job
  get-python-versions:
    runs-on: ubuntu-latest
    outputs:
      python-matrix: ${{ steps.get-python-versions-action.outputs.latest-python-versions }}
    steps:
    - uses: snok/latest-python-versions@v1
      id: get-python-versions-action
      with:
        min-version: 3.8
        include-prereleases: true

  # Then use the output from the previous job in the matrix definition
  test:
    needs: [linting, get-python-versions]
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ${{ fromJson(needs.get-python-versions.outputs.python-matrix) }}
    steps:
      - uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}

Contributing

Contributions are always welcome 👏