Skip to content

Commit

Permalink
Add new way to resolve version
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed May 26, 2024
1 parent a43ccc3 commit c298d39
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
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 == "stable":
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 == "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)

0 comments on commit c298d39

Please sign in to comment.