Issue 401 GitHub action outputs by lilfetz22 · Pull Request #1403 · python-semantic-release/python-semantic-release

added 6 commits

January 1, 2026 07:51
Add support for new GitHub Action outputs to expose release asset information:
- id: The release ID from the remote VCS
- upload_url: URL for uploading additional assets to the release
- assets: JSON array containing information about all uploaded assets
- assets_dist: JSON object of Python dist assets organized by type (wheel, sdist)

These outputs enable users to programmatically access release metadata and
uploaded asset information in their GitHub workflows. Asset information includes
details such as name, size, content_type, and browser_download_url.

Changes:
- Updated VersionGitHubActionsOutput class with new properties for release_id,
  upload_url, assets, and assets_dist
- Modified Github.create_release() to return ReleaseInfo namedtuple containing
  release ID, upload URL, and asset details
- Updated upload_release_asset() to return asset metadata from API response
- Added new output definitions to action.yml with detailed descriptions
- Updated type signatures across HVCS implementations to support ReleaseInfo
- Updated version command to populate new outputs after release creation

Implements: python-semantic-release#401
Adds comprehensive unit tests for the new GitHub Actions output properties:
- release_id property and validation
- upload_url property and validation
- assets list property and validation
- assets_dist computed property (categorizes by wheel/sdist)
- Output format includes new fields
- File writing with JSON serialization

Also updates existing test_version_github_actions_output_format to expect
the new fields in the output with proper line ending handling.
Adds documentation for the new GitHub Actions outputs:
- id: Release ID from GitHub API
- upload_url: URL for uploading additional assets
- assets: JSON array of all uploaded asset metadata
- assets_dist: JSON object organizing assets by type (wheel/sdist)

Includes a new 'Using Release Assets Outputs' example section demonstrating:
- How to download specific distribution files
- How to list all assets
- How to use the release ID with the GitHub API
Updates test_version_writes_github_actions_output to verify the new
output fields (id, upload_url, assets, assets_dist) are correctly
written to the GITHUB_OUTPUT file. When using --no-push, these fields
will be empty strings or empty JSON structures since no GitHub release
is created.
Wraps the conditional expression for multiline output values in
parentheses to improve readability and comply with code style
guidelines. This change improves the formatting of the list
comprehension that generates GitHub Actions output lines.

The logic remains unchanged - it still generates either a heredoc
format (<<EOF) for non-empty values or an empty assignment for
empty values.
Splits the logger.error() call across multiple lines to improve
code readability and comply with line length guidelines. The
error message formatting remains functionally identical.

This change addresses a formatting issue in the build_distributions
function where the error logging statement exceeded preferred line
length limits.