Skip to content

Commit

Permalink
Fix for Alpha version logic (#1)
Browse files Browse the repository at this point in the history
* [NO JIRA] Allow working with Alpha releases
  • Loading branch information
ibexa-yuna authored Oct 1, 2021
1 parent 63b30c5 commit 0fd08db
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
with:
currentTag: "v2.2.4"

- id: alphatest1
uses: ibexa/version-logic-action@master
with:
currentTag: "v4.0.0-alpha1"
prevFullTag: "v3.3.9"

- id: betatest1
uses: ibexa/version-logic-action@master
with:
Expand All @@ -47,6 +53,7 @@ jobs:
test "${{ steps.majortest.outputs.previousTag }}" == "v1.0.0"
test "${{ steps.minortest.outputs.previousTag }}" == "v2.2.0"
test "${{ steps.patchtest.outputs.previousTag }}" == "v2.2.3"
test "${{ steps.alphatest1.outputs.previousTag }}" == "v3.3.0"
test "${{ steps.betatest1.outputs.previousTag }}" == "v2.2.3"
test "${{ steps.betatest2.outputs.previousTag }}" == "v2.2.4-beta1"
test "${{ steps.rctest1.outputs.previousTag }}" == "v2.2.4-beta1"
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ description: "Uses Ibexa-specific rules to output previous tag for comparing"
author: "Petro Kurbatskyi"
inputs:
currentTag:
required: true
description: "Current tag"
default: "v1.0.0"
prevFullTag:
required: false
description: "Previous full release tag"
outputs:
previousTag:
description: "Output from the action"
runs:
using: "docker"
image: "docker://ghcr.io/ibexa/version-logic-action:v1.1.0"
image: "docker://ghcr.io/ibexa/version-logic-action:v1.2.0"
12 changes: 10 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@
def main():
# cut initial v from input
current_tag = os.environ["INPUT_CURRENTTAG"][1:]
# optional parameter
previous_full_tag = os.environ.get("INPUT_PREVFULLTAG")

major, minor, patch, prerelease, _ = semver.VersionInfo.parse(current_tag)
if previous_full_tag:
pft_ver = list(semver.VersionInfo.parse(previous_full_tag[1:]))
else:
pft_ver = list(semver.VersionInfo.parse(current_tag))
pft_ver[1] -= 1
pft_ver[2] = 0
if prerelease:
type, number = re.match('(?P<type>alpha|beta|rc)(?P<number>\d+)', prerelease).groups(['type', 'number'])
if type == 'beta' and number == '1':
if type in ['alpha', 'beta'] and number == '1':
# compare 3.3.0-beta1 with 3.2.0
# but if it's patch compare with last released patch
if not patch:
previous_tag = semver.format_version(major, minor - 1, 0)
previous_tag = semver.format_version(pft_ver[0], pft_ver[1], 0)
else:
previous_tag = semver.format_version(major, minor, patch - 1)
elif type == 'rc' and number == '1':
Expand Down

0 comments on commit 0fd08db

Please sign in to comment.