-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from sefasenturk95/main
Update version look up to support tags prepended with a prefix
- Loading branch information
Showing
7 changed files
with
159 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,21 @@ jobs: | |
[[ "${{ steps.version-via-api.outputs.patch-version }}" == "${{ steps.version-via-git.outputs.patch-version }}" ]] | ||
# Don't test the full version or pre-version, since the number of digits is likely to be different (9 via api vs. 7 via git) | ||
- name: Get next version via Git with tag-prefix | ||
uses: ./ | ||
id: version-prefix | ||
with: | ||
scheme: 'semver' | ||
use_api: false | ||
tag_prefix: 'foo/bar@' | ||
|
||
- name: Check that it starts from 0.0.1 (since prefix doesn't exist) | ||
shell: bash | ||
run: | | ||
[[ "${{ steps.version-prefix.outputs.current-version }}" == "0.0.0" ]] | ||
[[ "${{ steps.version-prefix.outputs.version }}" == "0.0.1" ]] | ||
[[ "${{ steps.version-prefix.outputs.prefixed-version }}" == "foo/[email protected]" ]] | ||
release: | ||
needs: | ||
- test-action-yml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,37 @@ function init_repo { | |
[[ "$output" = *"CURRENT_V_VERSION=v0.1.2"* ]] | ||
} | ||
|
||
@test "finds the current normal version with tag_prefix enabled" { | ||
init_repo | ||
|
||
export tag_prefix="@org/product@" | ||
|
||
git tag @org/[email protected] | ||
git tag @org/[email protected] | ||
git tag @org/[email protected] | ||
|
||
run version-lookup.sh | ||
|
||
print_run_info | ||
[ "$status" -eq 0 ] && | ||
[[ "$output" = *"CURRENT_VERSION=0.1.2"* ]] | ||
} | ||
|
||
@test "tag_prefix enabled prefixes with a v" { | ||
init_repo | ||
|
||
export tag_prefix="@org/product/" | ||
|
||
git tag @org/product/0.1.2 | ||
|
||
run version-lookup.sh | ||
|
||
print_run_info | ||
[ "$status" -eq 0 ] && | ||
[[ "$output" = *"CURRENT_VERSION=0.1.2"* ]] && | ||
[[ "$output" = *"CURRENT_V_VERSION=v0.1.2"* ]] | ||
} | ||
|
||
@test "finds the current normal version even if there's a newer pre-release version" { | ||
init_repo | ||
|
||
|
@@ -85,6 +116,24 @@ function init_repo { | |
[[ "$output" = *"CURRENT_VERSION=1.2.300"* ]] | ||
} | ||
|
||
@test "finds only prefixed tags when tag_prefix set" { | ||
init_repo | ||
|
||
export tag_prefix="my_product-" | ||
|
||
git tag my_product-0.1.2 | ||
git tag my_product-0.1.3-dev.123 | ||
git tag 2.4.5 | ||
git tag 2.4.6-dev.456 | ||
|
||
run version-lookup.sh | ||
|
||
print_run_info | ||
[ "$status" -eq 0 ] && | ||
[[ "$output" = *"CURRENT_VERSION=0.1.2"* ]] && | ||
[[ "$output" = *"CURRENT_V_VERSION=v0.1.2"* ]] | ||
} | ||
|
||
@test "returns 0.0.0 if no normal version detected" { | ||
init_repo | ||
|
||
|
@@ -107,6 +156,20 @@ function init_repo { | |
[[ "$output" = *"CURRENT_VERSION=0.0.0"* ]] | ||
} | ||
|
||
@test "returns 0.0.0 if no prefix version detected even if there's a non-prefix release version" { | ||
init_repo | ||
|
||
export tag_prefix="code/" | ||
|
||
git tag 0.1.0 | ||
|
||
run version-lookup.sh | ||
|
||
print_run_info | ||
[ "$status" -eq 0 ] && | ||
[[ "$output" = *"CURRENT_VERSION=0.0.0"* ]] | ||
} | ||
|
||
@test "returns a calver if no normal version detected and calver scheme specified" { | ||
init_repo | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters