5 Commits

Author SHA1 Message Date
Philip Jay
822afeb70c Merge pull request #10 from reecetech/DE-4401-fix-for-pipefails
Avoid broken pipe exits (`141`) when `head` exits
2022-02-01 16:52:07 +11:00
Phil Jay
9492ff84fb Avoid broken pipe exits (141) when head exits
Intermittent issue, only observed on self-hosted agents on VMware (due
to multi-core processing)
2022-02-01 12:23:49 +11:00
Philip Jay
7c6e26cbd9 Merge pull request #9 from reecetech/v-prefix
Add `v` prefixed version output
2021-11-22 10:04:07 +11:00
Phil Jay
38a48eeef1 Add v prefixed version outputs
See: https://github.com/reecetech/version-increment/issues/8
2021-11-15 06:54:57 +11:00
Phil Jay
4988018178 Add tests for v prefixed version output 2021-11-15 06:54:21 +11:00
5 changed files with 38 additions and 7 deletions

View File

@@ -9,7 +9,7 @@
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Get next version - name: Get next version
uses: reecetech/version-increment@2021.11.1 uses: reecetech/version-increment@2021.11.2
id: version id: version
with: with:
scheme: semver scheme: semver
@@ -82,10 +82,12 @@ Examples:
### 📤 Outputs ### 📤 Outputs
| name | description | | name | description |
| :--- | :--- | | :--- | :--- |
| current_version | The current latest version detected from the git repositories tags | | current-version | The current latest version detected from the git repositories tags |
| version | The incremented version number (e.g. the next version) | | current-v-version | The current latest version detected from the git repositories tags, prefixed with a `v` character |
| version | The incremented version number (e.g. the next version) |
| v-version | The incremented version number (e.g. the next version), prefixed with a `v` character |
## 💕 Contributing ## 💕 Contributing

View File

@@ -104,6 +104,20 @@ function init_repo {
[[ "$output" = *"::set-output name=version::2.0.0"* ]] [[ "$output" = *"::set-output name=version::2.0.0"* ]]
} }
@test "prefixes with v" {
init_repo
export current_version=1.2.3
export increment="major"
run ../../version-increment.sh
print_run_info
[ "$status" -eq 0 ] &&
[[ "$output" = *"::set-output name=version::2.0.0"* ]] &&
[[ "$output" = *"::set-output name=v-version::v2.0.0"* ]]
}
@test "increments to a new month (calver)" { @test "increments to a new month (calver)" {
init_repo init_repo

View File

@@ -43,6 +43,19 @@ function init_repo {
[[ "$output" = *"::set-output name=current-version::0.1.2"* ]] [[ "$output" = *"::set-output name=current-version::0.1.2"* ]]
} }
@test "prefixes with a v" {
init_repo
git tag 0.1.2
run ../../version-lookup.sh
print_run_info
[ "$status" -eq 0 ] &&
[[ "$output" = *"::set-output name=current-version::0.1.2"* ]] &&
[[ "$output" = *"::set-output name=current-v-version::v0.1.2"* ]]
}
@test "finds the current normal version even if there's a newer pre-release version" { @test "finds the current normal version even if there's a newer pre-release version" {
init_repo init_repo

View File

@@ -87,3 +87,4 @@ fi
echo " The new version is ${new_version}" echo " The new version is ${new_version}"
echo "::set-output name=version::${new_version}" echo "::set-output name=version::${new_version}"
echo "::set-output name=v-version::v${new_version}"

View File

@@ -34,11 +34,11 @@ fi
## Version parsing ## Version parsing
# detect current version - removing "v" from start of tag if it exists # detect current version - removing "v" from start of tag if it exists
current_version="$(git tag -l | { ${grep} -P "${pcre_allow_vprefix}" || true; } | sed 's/^v//g' | sort -V --reverse | head -n1)" current_version="$(git tag -l | { ${grep} -P "${pcre_allow_vprefix}" || true; } | sed 's/^v//g' | sort -V | tail -n 1)"
# support transition from an old reecetech calver style (yyyy-mm-Rr, where R is the literal `R`, and r is the nth release for the month) # support transition from an old reecetech calver style (yyyy-mm-Rr, where R is the literal `R`, and r is the nth release for the month)
if [[ -z "${current_version:-}" ]] ; then if [[ -z "${current_version:-}" ]] ; then
current_version="$(git tag -l | { ${grep} -P "${pcre_old_calver}" || true; } | sort -V --reverse | head -n1)" current_version="$(git tag -l | { ${grep} -P "${pcre_old_calver}" || true; } | sort -V | tail -n 1)"
if [[ -n "${current_version:-}" ]] ; then if [[ -n "${current_version:-}" ]] ; then
# convert - to . and drop leading zeros & the R # convert - to . and drop leading zeros & the R
current_version="$(echo "${current_version}" | sed -r 's/^([0-9]+)-0{0,1}([0-9]+)-R0{0,1}([0-9]+)$/\1.\2.\3/')" current_version="$(echo "${current_version}" | sed -r 's/^([0-9]+)-0{0,1}([0-9]+)-R0{0,1}([0-9]+)$/\1.\2.\3/')"
@@ -62,3 +62,4 @@ fi
echo " The current normal version is ${current_version}" echo " The current normal version is ${current_version}"
echo "::set-output name=current-version::${current_version}" echo "::set-output name=current-version::${current_version}"
echo "::set-output name=current-v-version::v${current_version}"