Skip to content

Commit

Permalink
EZP-32364: Add Version Logic action
Browse files Browse the repository at this point in the history
  • Loading branch information
ibexa-yuna committed Mar 24, 2021
1 parent e2cd0d3 commit 7a29b09
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 123 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Self test
id: selftest

# Put your action repo here
uses: jacobtomlinson/python-container-action@master
- id: selftest1

uses: ibexa-yuna/version-logic-action@master
with:
currentTag: "v2.2.4"
- id: selftest2

uses: ibexa-yuna/version-logic-action@master
with:
currentTag: "v2.0.0"
- id: selftest3

uses: ibexa-yuna/version-logic-action@master
with:
currentTag: "v2.3.0"

- name: Check outputs
run: |
test "${{ steps.selftest.outputs.myOutput }}" == "Hello world"
test "${{ steps.selftest1.outputs.previousTag }}" == "v2.2.3"
test "${{ steps.selftest2.outputs.previousTag }}" == "v1.0.0"
test "${{ steps.selftest3.outputs.previousTag }}" == "v2.2.0"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ADD . /app
WORKDIR /app

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

# A distroless container image with Python and some basics like SSL certificates
# https://github.com/GoogleContainerTools/distroless
Expand Down
22 changes: 0 additions & 22 deletions LICENSE

This file was deleted.

85 changes: 0 additions & 85 deletions README.md

This file was deleted.

14 changes: 7 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: "Python Container Action Template"
description: "Get started with Python Container actions"
author: "Jacob Tomlinson"
name: "Version Logic action"
description: "Uses Ibexa-specific rules to output previous tag for comparing"
author: "Petro Kurbatskyi"
inputs:
myInput:
description: "Input to use"
default: "world"
currentTag:
description: "Current tag"
default: "v1.0.0"
outputs:
myOutput:
previousTag:
description: "Output from the action"
runs:
using: "docker"
Expand Down
14 changes: 11 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import os
import requests # noqa We are just importing this to prove the dependency installed correctly
import semver


def main():
my_input = os.environ["INPUT_MYINPUT"]
# cut initial v from input
current_tag = os.environ["INPUT_CURRENTTAG"][1:]

my_output = f"Hello {my_input}"
major, minor, patch, _, _ = semver.VersionInfo.parse(current_tag)
if not patch and not minor:
previous_tag = semver.format_version(major - 1, 0, 0)
elif not patch:
previous_tag = semver.format_version(major, minor - 1, 0)
else:
previous_tag = semver.format_version(major, minor, patch - 1)

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


if __name__ == "__main__":
Expand Down

0 comments on commit 7a29b09

Please sign in to comment.