This GitHub Action extracts the release version from the repox status on a specified branch and makes it available as both an output and environment variable.
The action retrieves the release version by:
- Calling the GitHub API to get the commit status for the specified branch (defaults to master)
- Filtering for statuses with context starting with
repox - Extracting the version from the status description using jq
- Setting the version as both an action output and environment variable
This action requires the statuses: read permission for the GitHub token to access repository commit statuses via the GitHub API.
This action depends on:
ghCLI tool (GitHub CLI) for API accessjqfor JSON parsing (used within the gh command)
| Input | Description | Required | Default |
|---|---|---|---|
github-token |
The GitHub token for API calls | No | ${{ github.token }} |
branch |
The branch from which to get the version | No | master |
| Output | Description |
|---|---|
release-version |
The extracted release version from repox status |
After successful execution, the following environment variable is set:
| Variable | Description |
|---|---|
RELEASE_VERSION |
The extracted release version from repox status |
- name: Get Release Version
id: get-version
uses: SonarSource/release-github-actions/get-release-version@v1
- name: Use the release version
run: |
echo "Release version: ${{ steps.get-version.outputs.release-version }}"
echo "From environment: $RELEASE_VERSION"- name: Get Release Version
id: get-version
uses: SonarSource/release-github-actions/get-release-version@v1
with:
github-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}- name: Get Release Version from specific branch
id: get-version
uses: SonarSource/release-github-actions/get-release-version@v1
with:
branch: someone/some_new_featureThe action uses a shell script that:
- Executes the gh CLI command:
gh api "/repos/{owner/repo}/commits/{branch}/status" --jq ".statuses[] | select(.context | startswith(\"repox\")) | .description | split(\"'\")[1]" - Uses the standard GitHub context
${{ github.repository }}to get the repository owner and name - Uses the specified branch input (defaults to master if not provided)
- Validates that a version was successfully extracted
- Sets both
GITHUB_OUTPUTandGITHUB_ENVfor maximum compatibility
The action will fail with a non-zero exit code if:
- The GitHub API call fails
- No
repoxstatus is found - The version cannot be extracted from the status description
- The extracted version is empty
- This action assumes that the
repoxstatus contains the version in a specific format within single quotes - The action works with any context that starts with
repox(e.g.,repox-master,someone/some_new_feature) - The action requires read access to the repository's commit statuses
- The
ghCLI tool must be available in the runner environment (it's pre-installed on GitHub-hosted runners)