Skip to content

Commit

Permalink
Add disable_pre_release to force normal version increment
Browse files Browse the repository at this point in the history
  • Loading branch information
narze committed Jun 19, 2024
1 parent c1faa9d commit 0c6d222
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Examples:
| increment | The digit to increment, either `major`, `minor` or `patch`, ignored if `scheme` == `calver` | No | `patch` |
| release_branch | Specify a non-default branch to use for the release tag (the one without -pre) | No | |
| use_api | Use the GitHub API to discover current tags, which avoids the need for a git checkout, but requires `curl` and `jq` | No | `false` |
| disable_pre_release | Always return a normal version, even if the branch is not the default branch | No | `false` |

### Outputs 📤

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ inputs:
type: string
use_api:
description: 'Use the GitHub API to discover current tags, which avoids the need for a git checkout, but requires `curl` and `jq`'
disable_pre_release:
description: "Disable pre-release versioning"
required: false
default: false

Expand Down Expand Up @@ -98,3 +100,4 @@ runs:
scheme: ${{ inputs.scheme }}
release_branch: ${{ inputs.release_branch }}
use_api: ${{ inputs.use_api }}
disable_pre_release: ${{ inputs.disable_pre_release }}
16 changes: 9 additions & 7 deletions version-increment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,16 @@ if [[ "${version_array[0]}" -gt 2020 && "${scheme}" != "calver" ]] ; then
fi

# add pre-release info to version if not the default branch
if [[ "${current_ref}" != "refs/heads/${default_branch}" ]] ; then
pre_release="pre.${git_commit}"
if [[ "${pep440:-}" == 'true' ]] ; then
new_version="${new_version}+${pre_release}"
else
new_version="${new_version}-${pre_release}"
if [[ "${disable_pre_release:-}" != 'true' ]] ; then
if [[ "${current_ref}" != "refs/heads/${default_branch}" ]] ; then
pre_release="pre.${git_commit}"
if [[ "${pep440:-}" == 'true' ]] ; then
new_version="${new_version}+${pre_release}"
else
new_version="${new_version}-${pre_release}"
fi
echo "PRE_RELEASE_LABEL=${pre_release}" >> "${GITHUB_OUTPUT}"
fi
echo "PRE_RELEASE_LABEL=${pre_release}" >> "${GITHUB_OUTPUT}"
fi

if [[ -z "$(echo "${new_version}" | grep_p "${pcre_semver}")" ]] ; then
Expand Down

0 comments on commit 0c6d222

Please sign in to comment.