Skip to content

Commit

Permalink
Merge pull request #23 from ps-jay/main
Browse files Browse the repository at this point in the history
Introduce test for `release_branch`, & update README
  • Loading branch information
ps-jay authored Sep 17, 2023
2 parents 0974302 + 4682082 commit 4846cba
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ Examples:

### 📥 Inputs

| name | description | required | default |
| :--- | :--- | :--- | :--- |
| scheme | The versioning scheme in-use, either `semver` or `calver` | No | `semver` |
| pep440 | Set to `true` for PEP440 compatibility of _pre-release_ versions by making use of the build metadata segment of semver, which maps to local version identifier in PEP440 | No | `false` |
| increment | The digit to increment, either `major`, `minor` or `patch`, ignored if `scheme` == `calver` | No | `patch` |
| name | description | required | default |
| :--- | :--- | :--- | :--- |
| scheme | The versioning scheme in-use, either `semver` or `calver` | No | `semver` |
| pep440 | Set to `true` for PEP440 compatibility of _pre-release_ versions by making use of the build metadata segment of semver, which maps to local version identifier in PEP440 | No | `false` |
| 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 | |

### 📤 Outputs

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inputs:
required: false
default: 'patch'
release_branch:
description: "Specify a non-main branch to use for the release tag (the one without -prerelease). If empty, will use the default branch for the repo."
description: 'Specify a non-default branch to use for the release tag (the one without -pre)'
required: false
type: string

Expand Down
16 changes: 16 additions & 0 deletions tests/test_version-increment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,22 @@ function init_repo {
[[ "$output" = *"VERSION=1.2.4-pre.${short_ref}"* ]]
}

@test "does not append prerelease information if on a specified release_branch" {
init_repo

export current_version=1.2.3
export GITHUB_REF="refs/heads/releases"
export release_branch="releases"

run ../../version-increment.sh

print_run_info
[ "$status" -eq 0 ] &&
[[ "$output" != *"PRE_RELEASE_LABEL=pre."* ]] &&
[[ "$output" != *"VERSION=1.2.4-pre."* ]] &&
[[ "$output" = *"VERSION=1.2.4"* ]]
}

@test "appends prerelease information in pep440 compatible way when pep440 is true" {
init_repo

Expand Down
2 changes: 1 addition & 1 deletion version-increment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if [[ -z "${BATS_VERSION:-}" ]] ; then
default_branch="$(git remote show origin | ${grep} 'HEAD branch' | cut -d ' ' -f 5)"
fi
# use release_branch if not empty
if [[ -n "${release_branch}" ]] ; then
if [[ -n "${release_branch:-}" ]] ; then
default_branch="${release_branch}"
fi

Expand Down

0 comments on commit 4846cba

Please sign in to comment.