Compare commits

..

31 Commits

Author SHA1 Message Date
4906d867d0 Iteration 2023-07-22 05:38:34 -04:00
930d1b14b1 Iteration 2023-07-22 05:30:49 -04:00
02fe81d919 Iteration 2023-07-22 05:30:02 -04:00
849874cec6 Iteration 2023-07-22 05:28:03 -04:00
da1e716dde GitHub Actions Iterations 2023-07-22 05:24:36 -04:00
d2a3d5de6f GitHub Actions Iterations 2023-07-22 05:17:53 -04:00
f5204b496f GitHub Actions Iterations 2023-07-22 05:16:32 -04:00
3eb8b3da81 GitHub Actions Iterations 2023-07-22 05:15:27 -04:00
405ce258f2 GitHub Actions Iterations 2023-07-22 05:12:45 -04:00
1138c97865 GitHub Actions Iterations 2023-07-22 05:11:51 -04:00
8b214aab3d GitHub Actions Iterations 2023-07-22 05:11:03 -04:00
6a2b5da00b GitHub Actions Iterations 2023-07-22 05:09:18 -04:00
5c9bcfdac2 GitHub Actions Iterations 2023-07-22 05:04:59 -04:00
05b2278154 GitHub Actions Iterations 2023-07-22 05:03:40 -04:00
8976f24186 toml 2023-07-22 05:03:12 -04:00
2de8d7d597 GitHub Actions Iterations 2023-07-22 05:02:52 -04:00
29daef3b46 GitHub Actions Iterations 2023-07-22 04:59:16 -04:00
98fb6dada1 GitHub Actions Iterations 2023-07-22 04:57:52 -04:00
81f0cf33aa GitHub Actions Iterations 2023-07-22 04:54:53 -04:00
4d25ef7719 GitHub Actions Iterations 2023-07-22 04:52:29 -04:00
eecdc5661d GitHub Actions Iterations 2023-07-22 04:51:42 -04:00
f36e7be2d8 GitHub Actions Iterations 2023-07-22 04:51:11 -04:00
a273f83873 GitHub Actions Iterations 2023-07-22 04:50:33 -04:00
0ae43a314a GitHub Actions Iterations 2023-07-22 04:49:16 -04:00
df27ad2041 GitHub Actions Iterations 2023-07-22 04:48:41 -04:00
06671174b2 GitHub Actions Iterations 2023-07-22 04:48:03 -04:00
036b720f2e GitHub Actions Iterations 2023-07-22 04:47:13 -04:00
b6bfc2409c Add unit test workflow 2023-07-22 04:46:03 -04:00
28eaf580b4 Get config properly 2023-07-02 23:32:31 -04:00
fa41212e77 Rework get_version and various improvements 2023-07-02 23:03:34 -04:00
d1e2d77a29 Implement unittests 2023-07-02 18:29:32 -04:00
5 changed files with 79 additions and 33 deletions

View File

@ -4,6 +4,7 @@ on:
push:
branches:
- master
- feature/refactor
pull_request: {}
jobs:

View File

@ -1,33 +1,29 @@
# ======= #
# Builder #
# ======= #
FROM python:3.11-slim as builder
COPY / /semver
RUN pip wheel --no-cache-dir --wheel-dir /wheels /semver
FROM centos/python-36-centos7
# ======== #
# Finalize #
# ======== #
FROM python:3.11-slim
USER root
# Update and install git
RUN apt-get update && apt-get install -y git
# Create user
RUN mkdir /semver && \
groupadd -g 10001 semver && \
useradd -u 10000 -g semver -d /semver semver \
&& chown -R semver:semver /semver
# Prep workspace
RUN mkdir /workspace && \
chown -R semver:semver /workspace
VOLUME /workspace
#Perform updates
RUN pip install --upgrade pip
RUN yum update -y
RUN yum -y remove git
RUN yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm
RUN yum -y install git
#Setup semver
COPY --from=builder /wheels /semver/wheels
RUN pip install --no-cache /semver/wheels/*
ADD / /semver
WORKDIR /semver
RUN python setup.py sdist
RUN pip install dist/semver-*.tar.gz
USER semver:semver
# Prep workspace
RUN mkdir /workspace
WORKDIR /workspace
ENTRYPOINT [ "semver" ]
VOLUME /workspace
#Permissions
RUN useradd -d /semverUser semverUser
RUN chown -R semverUser:semverUser /workspace
CMD [ "semver" ]
USER semverUser

View File

@ -27,19 +27,19 @@ def main():
"""Main entry point for the application"""
parser = argparse.ArgumentParser(description="Bump Semantic Version.")
parser.add_argument(
"-n", "--no-push", help="do not try to push", action="store_false", dest="push"
"-n", "--no-push", help="Do not try to push", action="store_false", dest="push"
)
parser.add_argument(
"-g",
"--global-user",
help="set git user at a global level",
help="Set git user at a global level, helps in jenkins",
action="store_true",
dest="global_user",
)
parser.add_argument(
"-D",
"--debug",
help="sets logging level to DEBUG",
help="Sets logging level to DEBUG",
action="store_true",
dest="debug",
default=False,

View File

@ -11,14 +11,14 @@ def main():
parser.add_argument(
"-d",
"--dot",
help="switch out / for . to be used in docker tag",
help="Switch out / for . to be used in docker tag",
action="store_true",
dest="dot",
)
parser.add_argument(
"-D",
"--debug",
help="sets logging level to DEBUG",
help="Sets logging level to DEBUG",
action="store_true",
dest="debug",
default=False,
@ -26,12 +26,12 @@ def main():
parser.add_argument(
"-f",
"--format",
help="format for pre-release version syntax",
help="Format for pre-release version syntax",
choices=["npm", "maven", "docker"],
default=None,
)
parser.add_argument(
"-b", "--build-number", help="build number, used in pre-releases", default=0
"-b", "--build-number", help="Build number, used in pre-releases", default=0
)
args = parser.parse_args()

49
semver/scm/perforce.py Normal file
View File

@ -0,0 +1,49 @@
import subprocess
from typing import Union, List
import toml
from semver.scm import SCM
from semver.logger import logger
class Perforce(SCM):
def __init__(self) -> None:
super().__init__()
def get_tag_version(self) -> str:
"""
Get the latest tagged version from Perforce labels
:return: The latest tagged version
"""
config: dict = toml.load("./.bumpversion.cfg")
tag_expression: str = config["bumpversion"]["tag_name"].replace(
"{new_version}", "[0-9]*.[0-9]*.[0-9]*"
)
logger.debug("Tag expression: " + str(tag_expression))
# Default version is `0.0.0` or what is found in
version = self.get_file_version(config)
# If a version is found in Perforce labels, use that the latest labeled version
labeled_versions: Union[List[str], None] = None
try:
proc = subprocess.run(
["p4", "labels", "-e", tag_expression, "-m1"],
capture_output=True,
text=True,
check=True,
)
labeled_versions = proc.stdout.rstrip().split("\n")
except subprocess.CalledProcessError as e:
raise RuntimeError(
f"Error getting latest labeled Perforce version: {str(e.stderr).rstrip()}"
)
if len(labeled_versions) > 0 and labeled_versions[-1] != "":
version = labeled_versions[-1]
logger.debug("Label Version: " + str(version))
return version