From 8b854651df1d2c00724a98804f4eac7355acbeda Mon Sep 17 00:00:00 2001 From: karunasa Date: Thu, 10 Feb 2022 16:56:32 +1100 Subject: [PATCH 1/3] Exposing major, minor and patch numbers as outputs --- README.md | 5 ++++- action.yml | 9 +++++++++ version-increment.sh | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25c6ac9..2a1b53e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ uses: actions/checkout@v2 - name: Get next version - uses: reecetech/version-increment@2022.2.3 + uses: reecetech/version-increment@2022.2.4 id: version with: scheme: semver @@ -88,6 +88,9 @@ Examples: | 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 | +| major-version | Major number of the incremented version | +| minor-version | Minor number of the incremented version | +| patch-version | Patch number of the incremented version | ## 💕 Contributing diff --git a/action.yml b/action.yml index e157f87..eec63da 100644 --- a/action.yml +++ b/action.yml @@ -32,6 +32,15 @@ outputs: v-version: description: 'Incremented version calculated, prefixed with a `v` charatcter' value: ${{ steps.version-increment.outputs.v-version }} + major-version: + description: 'Major number of the incremented version' + value: ${{ steps.version-increment.outputs.major-version }} + minor-version: + description: 'Minor number of the incremented version' + value: ${{ steps.version-increment.outputs.minor-version }} + patch-version: + description: 'Patch number of the incremented version' + value: ${{ steps.version-increment.outputs.patch-version }} runs: using: "composite" diff --git a/version-increment.sh b/version-increment.sh index f8c29b7..ebf7cee 100755 --- a/version-increment.sh +++ b/version-increment.sh @@ -88,3 +88,6 @@ echo "â„šī¸ The new version is ${new_version}" echo "::set-output name=version::${new_version}" echo "::set-output name=v-version::v${new_version}" +echo "::set-output name=major-version::v${version_array[0]}" +echo "::set-output name=minor-version::v${version_array[1]}" +echo "::set-output name=patch-version::v${version_array[2]}" From fde70f2da949d1c5bbaeb0acb302b2c7ddb5aef4 Mon Sep 17 00:00:00 2001 From: Phil Jay Date: Thu, 10 Feb 2022 22:27:23 +1100 Subject: [PATCH 2/3] Add tests for new desired output --- tests/test_version-increment.bats | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_version-increment.bats b/tests/test_version-increment.bats index 3f638d3..457e815 100644 --- a/tests/test_version-increment.bats +++ b/tests/test_version-increment.bats @@ -75,6 +75,9 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && + [[ "$output" = *"::set-output name=major-version::1"* ]] && + [[ "$output" = *"::set-output name=minor-version::2"* ]] && + [[ "$output" = *"::set-output name=patch-version::4"* ]] && [[ "$output" = *"::set-output name=version::1.2.4"* ]] } @@ -88,6 +91,9 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && + [[ "$output" = *"::set-output name=major-version::1"* ]] && + [[ "$output" = *"::set-output name=minor-version::3"* ]] && + [[ "$output" = *"::set-output name=patch-version::0"* ]] && [[ "$output" = *"::set-output name=version::1.3.0"* ]] } @@ -101,6 +107,9 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && + [[ "$output" = *"::set-output name=major-version::2"* ]] && + [[ "$output" = *"::set-output name=minor-version::0"* ]] && + [[ "$output" = *"::set-output name=patch-version::0"* ]] && [[ "$output" = *"::set-output name=version::2.0.0"* ]] } @@ -115,6 +124,9 @@ function init_repo { print_run_info [ "$status" -eq 0 ] && [[ "$output" = *"::set-output name=version::2.0.0"* ]] && + [[ "$output" = *"::set-output name=major-v-version::v2"* ]] && + [[ "$output" = *"::set-output name=minor-v-version::v0"* ]] && + [[ "$output" = *"::set-output name=patch-v-version::v0"* ]] && [[ "$output" = *"::set-output name=v-version::v2.0.0"* ]] } From ba14b463c4b2d58e7ae16f3c2710740dc8737571 Mon Sep 17 00:00:00 2001 From: Phil Jay Date: Thu, 10 Feb 2022 22:27:59 +1100 Subject: [PATCH 3/3] Add both "plain" and `v` prefix version outputs --- README.md | 3 +++ action.yml | 9 +++++++++ version-increment.sh | 9 ++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2a1b53e..35d12c1 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,9 @@ Examples: | major-version | Major number of the incremented version | | minor-version | Minor number of the incremented version | | patch-version | Patch number of the incremented version | +| major-v-version | Major number of the incremented version, prefixed with a `v` character | +| minor-v-version | Minor number of the incremented version, prefixed with a `v` character | +| patch-v-version | Patch number of the incremented version, prefixed with a `v` character | ## 💕 Contributing diff --git a/action.yml b/action.yml index eec63da..3e496a1 100644 --- a/action.yml +++ b/action.yml @@ -41,6 +41,15 @@ outputs: patch-version: description: 'Patch number of the incremented version' value: ${{ steps.version-increment.outputs.patch-version }} + major-v-version: + description: 'Major number of the incremented version, prefixed with a `v` charatcter' + value: ${{ steps.version-increment.outputs.major-v-version }} + minor-v-version: + description: 'Minor number of the incremented version, prefixed with a `v` charatcter' + value: ${{ steps.version-increment.outputs.minor-v-version }} + patch-v-version: + description: 'Patch number of the incremented version, prefixed with a `v` charatcter' + value: ${{ steps.version-increment.outputs.patch-v-version }} runs: using: "composite" diff --git a/version-increment.sh b/version-increment.sh index ebf7cee..278d38b 100755 --- a/version-increment.sh +++ b/version-increment.sh @@ -88,6 +88,9 @@ echo "â„šī¸ The new version is ${new_version}" echo "::set-output name=version::${new_version}" echo "::set-output name=v-version::v${new_version}" -echo "::set-output name=major-version::v${version_array[0]}" -echo "::set-output name=minor-version::v${version_array[1]}" -echo "::set-output name=patch-version::v${version_array[2]}" +echo "::set-output name=major-version::${version_array[0]}" +echo "::set-output name=minor-version::${version_array[1]}" +echo "::set-output name=patch-version::${version_array[2]}" +echo "::set-output name=major-v-version::v${version_array[0]}" +echo "::set-output name=minor-v-version::v${version_array[1]}" +echo "::set-output name=patch-v-version::v${version_array[2]}"