diff --git a/.github/workflows/ci-supported-pythons.yml b/.github/workflows/ci-supported-pythons.yml index a5afec9..07a3716 100644 --- a/.github/workflows/ci-supported-pythons.yml +++ b/.github/workflows/ci-supported-pythons.yml @@ -29,10 +29,10 @@ jobs: path: structlog outputs: - python-versions: ${{ steps.baipp.outputs.supported_pythons_json_array }} + python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }} # If your matrix consists only of Python versions, you can use the # following, too: - # python-versions: ${{ steps.baipp.outputs.supported_pythons_json_job_matrix_value }} + # python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_job_matrix_value }} test-package: needs: build-package @@ -44,11 +44,10 @@ jobs: python-version: ${{ fromJson(needs.build-package.outputs.python-versions) }} # If you set 'python-versions' to - # 'supported_pythons_json_job_matrix_value' + # 'supported_python_classifiers_json_job_matrix_value' # above, you would set the matrix like this instead: # matrix: ${{ fromJson(needs.build-package.outputs.python-versions) }} - steps: - uses: actions/setup-python@v5 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d3d384..84b8215 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Added -- New outputs: `steps.supported-pythons-setter.outputs.supported_pythons_json_array` and `steps.supported-pythons-setter.outputs.supported_pythons_json_job_matrix_value`. +- New outputs: `steps.supported-pythons-setter.outputs.supported_python_classifiers_json_array` and `steps.supported-pythons-setter.outputs.supported_python_classifiers_json_job_matrix_value`. They are extracted from the trove classifiers defined in the package metadata (for example, `Programming Language :: Python :: 3.12`) and allow you to define the Python versions matrix for your CI jobs without duplicating this information. [#80](https://github.com/hynek/build-and-inspect-python-package/pull/80) diff --git a/action.yml b/action.yml index 37ec80b..12e6236 100644 --- a/action.yml +++ b/action.yml @@ -23,16 +23,20 @@ outputs: dist: description: The location of the built packages. value: ${{ steps.dist-location-setter.outputs.dist }} - supported_pythons_json_array: - description: A JSON array that contains all declared supported Python versions. - value: ${{ steps.supported-pythons-setter.outputs.supported_pythons_json_array }} - supported_pythons_json_job_matrix_value: + supported_python_classifiers_json_array: description: > - A JSON mapping from "python-version" to a list of all declared supported - Python versions. When loaded using the 'fromJson' function, this can be - used to define a job matrix that tests against all supported Python - versions. - value: ${{ steps.supported-pythons-setter.outputs.supported_pythons_json_job_matrix_value }} + A JSON array that contains all classifier-declared supported Python + versions. When loaded using the 'fromJson' function, this can be assigned + to a matrix strategy key (for example, `python-version`). + + value: ${{ steps.supported-pythons-setter.outputs.supported_python_classifiers_json_array }} + supported_python_classifiers_json_job_matrix_value: + description: > + Same as 'supported_python_classifiers_json_array', except it's already a + JSON mapping from "python-version" to a list of all classifier-declared + supported Python versions. In other words, you can assign it directly to + the 'strategy.matrix' key. + value: ${{ steps.supported-pythons-setter.outputs.supported_python_classifiers_json_job_matrix_value }} runs: using: composite @@ -189,6 +193,6 @@ runs: version_tokens = [ m.group(1).strip() for l in sys.stdin.readlines() if (m := match_classifier(l)) ] - print(f"supported_pythons_json_array={json.dumps(version_tokens)}") - print(f"""supported_pythons_json_job_matrix_value={json.dumps({"python-version": version_tokens})}""") + print(f"supported_python_classifiers_json_array={json.dumps(version_tokens)}") + print(f"""supported_python_classifiers_json_job_matrix_value={json.dumps({"python-version": version_tokens})}""") ' >> $GITHUB_OUTPUT