Skip to content

Output the package name #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ jobs:
path: structlog
upload-name-suffix: "-structlog-${{ matrix.os }}"

- run: echo Packages can be found at ${{ steps.baipp.outputs.dist }} and in artifact ${{ steps.baipp.outputs.artifact-name }}
- run: >
echo "Packages for ${{ steps.baipp.outputs.package_name }} (${{ steps.baipp.outputs.package_version }})
can be found at ${{ steps.baipp.outputs.dist }}
and in artifact ${{ steps.baipp.outputs.artifact-name }}"

check-pytest:
name: Build & verify the pytest package.
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ While *build-and-inspect-python-package* will build a wheel for you by default,

This is useful if you only want to define a matrix based on Python versions, because then you can just assign this to `strategy.matrix`.

- `package_name`: The name of the package as extracted from the package metadata.

- `package_version`: The version of the package as extracted from the package metadata.

This is useful, for example, for displaying the PyPI URL on the GitHub UI for the publishing job:
Expand All @@ -173,7 +175,7 @@ While *build-and-inspect-python-package* will build a wheel for you by default,
needs: baipp
environment:
name: pypi
url: https://pypi.org/project/structlog/${{ needs.baipp.outputs.package-version }}
url: https://pypi.org/project/${{ needs.baipp.outputs.package-name }}/${{ needs.baipp.outputs.package-version }}
```

### Artifacts
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ outputs:
supported Python versions. In other words, you can assign it directly to
the 'strategy.matrix' key.
value: ${{ steps.metadata-setter.outputs.supported_python_classifiers_json_job_matrix_value }}
package_name:
description: The name of the package.
value: ${{ steps.metadata-setter.outputs.package_name }}
package_version:
description: The version of the package as declared in the metadata.
value: ${{ steps.metadata-setter.outputs.package_version }}
Expand Down Expand Up @@ -251,8 +254,13 @@ runs:
if match := re.match(r"Programming Language :: Python :: (\d+\.\d+)$", classifier):
version_tokens.append(match.group(1))

package_name = pkg_info.get("Name")
if package_name is None:
raise RuntimeError("Package name is not set")

package_version = pkg_info.get("Version", "0.0.0")

print(f"package_name={package_name}")
print(f"package_version={package_version}")
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})}""")
Expand Down