diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 84c910a..fc99bc1 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -12,6 +12,7 @@ jobs: uses: ./ with: debug: true + version-to-resolve: 'stable' - uses: peter-evans/find-comment@v3 id: find_comment @@ -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 }} diff --git a/action.yml b/action.yml index 8a785dd..2113f86 100644 --- a/action.yml +++ b/action.yml @@ -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: @@ -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' @@ -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 diff --git a/entrypoint.py b/entrypoint.py index 1e0dc90..a22b62d 100644 --- a/entrypoint.py +++ b/entrypoint.py @@ -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)