Repository navigation
feat: add GitHub action outputs #401
Copy link
Copy link
Open
Labels
confirmedPrevent from becoming stalePrevent from becoming stalefeatureA new feature or a feature requestA new feature or a feature requestgood first issuea good start point for new contributorsa good start point for new contributorsneeds-updateNeeds status update from maintainersNeeds status update from maintainers
Milestone
Description
Description
Current GitHub action has some inputs, then it does something, but it has not usable outputs to check what the results were.
As a user of the GitHub action, i want several outputs, so that i can use them programmatically in GitHub workflows.
- released: bool(-ish) value that indicates whether a released happened
- version: (new) semantic version that was calculated. if
releasedwasfalsethan this would be the current version detected. - tag: VCS tag-name was used for the release. if
releasedwasfalsethan this would be empty string. - url: Github.com URL for the release. if
releasedisfalse, then this value is empty string - id: Release ID. if
releasedisfalse, then this value isnull - assets: JSON array containing information about each uploaded asset, in the format given here (minus the uploader field). if
releasedisfalse, then this value is an empty JSON list - assets-dist: JSON object containing information about each uploaded dist asset, in the format given here (minus the uploader field). if
releasedisfalse, then this value is an empty JSON object - upload_url: URL for uploading assets to the release. if
releasedisfalse, then this value is an empty string
output inspired by https://github.com/softprops/action-gh-release
Use cases
- released: python-semantic-release GitHub action might detect that no release should happen. To indicate this, you can check this value. As an example, you can use
${{ steps.<step-id>.outputs.released }}to check if a release happened and control other steps based on that information. For example, a DockerHub release can be skipped, if python-semantic-release did not happen, although the GitHub action ended withsuccess()state. - version: As an example, you can use
${{ steps.<step-id>.outputs.version }}to get the version that was currently detected/used for the release. - tag: As an example, you can use
${{ steps.<step-id>.outputs.tag }}as an input for https://github.com/marketplace/actions/upload-files-to-a-github-release - assets: As an example, you can use
${{ fromJSON(steps.<step-id>.outputs.assets-dist)[0].browser_download_url }}to get the download URL of the first asset. This file can then be downloaded and put in a docker image. - asset-dist: As an example, you can use
${{ fromJSON(steps.<step-id>.outputs.assets-dist).wheel.browser_download_url }}to get the download URL of the wheel-dist asset. This file can then be downloaded and put in a docker image. - upload_url: As an example, you can use
${{ steps.<step-id>.outputs.upload_url }}as an input for https://github.com/actions/upload-release-asset
Possible implementation
- outputs can be defined in the https://github.com/relekang/python-semantic-release/blob/master/action.yml
- output can be issued via workflow commands on stdOut - see https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions
alaprint('::set-output name=version::1.2.3')- maybe there is a lib for that, or the sanitizers can be copied from https://github.com/actions/toolkit/blob/daf8bb00606d37ee2431d9b1596b88513dcf9c59/packages/core/src/command.ts#L80-L94 - output
releasedshould be booleantrue/`` so it is usable in expressions
Therefore, it seems like GitHub expression treats every non-empty string as true and empty string as false. - to print the needed output for "workflow commands" only when run in GitHub action, the code could check if a certain environment variable is present in GitHub action only. Maybe have an extra log-stream just for "workflow commands" that is dis/enabled based on the env
- detection that run in a GitHub action can be done via env vars that are set by GitHub actions anyway:
/usr/bin/docker run .... -e GITHUB_ACTIONS=true -e CI=true ....
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
confirmedPrevent from becoming stalePrevent from becoming stalefeatureA new feature or a feature requestA new feature or a feature requestgood first issuea good start point for new contributorsa good start point for new contributorsneeds-updateNeeds status update from maintainersNeeds status update from maintainers
Activity
[-]add GutHub action outputs[/-][+]feat: add GutHub action outputs[/+]jkowalleck commentedon Dec 27, 2021
@relekang are you open for the requested feature to have outputs on the GH-action?
Are you open for pull-requests for it?
How would you like the ideal implementation to be?
relekang commentedon Dec 27, 2021
This sounds great, open for pull-requests 😄
jkowalleck commentedon Dec 28, 2021
any hints/notes on the implementation?
any hint where to start?
any constraints architectural-wise or design-specific?
did not look at your code, yet. i am not certain if all the features may be feasible with current code.
i might just prepare a PR with the things i actually need and that are low-hanging :)
jkowalleck commentedon Jan 4, 2022
i might not find the time to implement it in the near future.
idea and some implementation details should be clear, docs are linked.
i am not sad if someone else tackles this topic. ;-)
could you add the "help wanted" label to this very issue, @relekang ?
danth commentedon Jan 4, 2022
@jkowalleck done :)
jbnjohnathan commentedon Feb 24, 2023
+1 on this. Would be very useful. For example I would like to build a docker image and upload it to Github container registry after the version was increased. To do this I both need to know if the version was increased, and what new version number it was increased to.
jkowalleck commentedon Feb 24, 2023
One year passed, and I still had no time to implement the feature.
@jbnjohnathan would you go ahead and tackle the thing?
20 remaining items
codejedi365 commentedon Nov 14, 2024
Still in backlog
github-actions commentedon Jan 15, 2025
It has been 60 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?
codejedi365 commentedon Jan 15, 2025
Still in backlog
github-actions commentedon Mar 17, 2025
It has been 60 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?
codejedi365 commentedon Mar 17, 2025
Still in backlog
github-actions commentedon May 18, 2025
It has been 60 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?
feat(github-actions): add asset-related outputs to GitHub Action
feat(github-actions): add asset-related outputs to GitHub Action