Skip to content
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

Add new way to resolve version #19

Merged
merged 1 commit into from
May 26, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
uses: ./
with:
debug: true
version-to-resolve: 'stable'

- uses: peter-evans/find-comment@v3
id: find_comment
Expand All @@ -29,6 +30,7 @@ jobs:
|_rc_|`${{ steps.agp-version-finder.outputs.latest-rc }}`|
|_beta_|`${{ steps.agp-version-finder.outputs.latest-beta }}`|
|_alpha_|`${{ steps.agp-version-finder.outputs.latest-alpha }}`|
|_resolved stable_|`${{ steps.agp-version-finder.outputs.resolved-version }}`|
edit-mode: replace
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ inputs:
description: 'if true, shows additional debug information'
required: false
default: 'false'
version-to-resolve:
description: 'Has to be one of `stable`, `alpha`, `beta`, `rc`. Will be translated into specific version, available under `outputs.resolved-version`'
required: false

outputs:
latest-alpha:
Expand All @@ -20,6 +23,9 @@ outputs:
latest-stable:
description: "Returns latest stable AGP version"
value: ${{ steps.run-action.outputs.latest-stable }}
resolved-version:
description: "Actual semver version resolved from `version-to-resolve`"
value: ${{ steps.run-action.outputs.resolved-version }}

branding:
color: 'green'
Expand All @@ -30,5 +36,6 @@ runs:
- id: run-action
env:
INPUT_DEBUG: ${{ inputs.debug }}
INPUT_VERSION_TO_RESOLVE: ${{ inputs.version-to-resolve }}
run: python3 '${{ github.action_path }}'/entrypoint.py
shell: bash
26 changes: 22 additions & 4 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,25 @@ def github_output(key, value):
rc_count={len(all_rc)}
""")

github_output(key="latest-stable", value=all_stable[-1])
github_output(key="latest-alpha", value=all_alpha[-1])
github_output(key="latest-beta", value=all_beta[-1])
github_output(key="latest-rc", value=all_rc[-1])
latest_stable = all_stable[-1]
latest_alpha = all_alpha[-1]
latest_beta = all_beta[-1]
latest_rc = all_rc[-1]

version_to_resolve = os.getenv("INPUT_VERSION_TO_RESOLVE", "")
if version_to_resolve in ["stable", "current"]:
resolved_version = latest_stable
elif version_to_resolve == "alpha":
resolved_version = latest_alpha
elif version_to_resolve == "beta":
resolved_version = latest_beta
elif version_to_resolve in ["release-candidate", "rc"]:
resolved_version = latest_rc
else:
resolved_version = ""

github_output(key="latest-stable", value=latest_stable)
github_output(key="latest-alpha", value=latest_alpha)
github_output(key="latest-beta", value=latest_beta)
github_output(key="latest-rc", value=latest_rc)
github_output(key="resolved-version", value=resolved_version)