Skip to content

Commit 7a29b09

Browse files
committed
EZP-32364: Add Version Logic action
1 parent e2cd0d3 commit 7a29b09

File tree

6 files changed

+37
-123
lines changed

6 files changed

+37
-123
lines changed

.github/workflows/integration.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,25 @@ jobs:
55
runs-on: ubuntu-latest
66
steps:
77
- uses: actions/checkout@master
8-
- name: Self test
9-
id: selftest
108

11-
# Put your action repo here
12-
uses: jacobtomlinson/python-container-action@master
9+
- id: selftest1
10+
11+
uses: ibexa-yuna/version-logic-action@master
12+
with:
13+
currentTag: "v2.2.4"
14+
- id: selftest2
15+
16+
uses: ibexa-yuna/version-logic-action@master
17+
with:
18+
currentTag: "v2.0.0"
19+
- id: selftest3
20+
21+
uses: ibexa-yuna/version-logic-action@master
22+
with:
23+
currentTag: "v2.3.0"
1324

1425
- name: Check outputs
1526
run: |
16-
test "${{ steps.selftest.outputs.myOutput }}" == "Hello world"
27+
test "${{ steps.selftest1.outputs.previousTag }}" == "v2.2.3"
28+
test "${{ steps.selftest2.outputs.previousTag }}" == "v1.0.0"
29+
test "${{ steps.selftest3.outputs.previousTag }}" == "v2.2.0"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ADD . /app
33
WORKDIR /app
44

55
# We are installing a dependency here directly into our app source dir
6-
RUN pip install --target=/app requests
6+
RUN pip install --target=/app requests semver
77

88
# A distroless container image with Python and some basics like SSL certificates
99
# https://github.com/GoogleContainerTools/distroless

LICENSE

Lines changed: 0 additions & 22 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 85 deletions
This file was deleted.

action.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: "Python Container Action Template"
2-
description: "Get started with Python Container actions"
3-
author: "Jacob Tomlinson"
1+
name: "Version Logic action"
2+
description: "Uses Ibexa-specific rules to output previous tag for comparing"
3+
author: "Petro Kurbatskyi"
44
inputs:
5-
myInput:
6-
description: "Input to use"
7-
default: "world"
5+
currentTag:
6+
description: "Current tag"
7+
default: "v1.0.0"
88
outputs:
9-
myOutput:
9+
previousTag:
1010
description: "Output from the action"
1111
runs:
1212
using: "docker"

main.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import os
22
import requests # noqa We are just importing this to prove the dependency installed correctly
3+
import semver
34

45

56
def main():
6-
my_input = os.environ["INPUT_MYINPUT"]
7+
# cut initial v from input
8+
current_tag = os.environ["INPUT_CURRENTTAG"][1:]
79

8-
my_output = f"Hello {my_input}"
10+
major, minor, patch, _, _ = semver.VersionInfo.parse(current_tag)
11+
if not patch and not minor:
12+
previous_tag = semver.format_version(major - 1, 0, 0)
13+
elif not patch:
14+
previous_tag = semver.format_version(major, minor - 1, 0)
15+
else:
16+
previous_tag = semver.format_version(major, minor, patch - 1)
917

10-
print(f"::set-output name=myOutput::{my_output}")
18+
print(f"::set-output name=previousTag::v{previous_tag}")
1119

1220

1321
if __name__ == "__main__":

0 commit comments

Comments
 (0)