buildtest/build.py

105 lines
2.4 KiB
Python
Raw Normal View History

2024-01-26 11:09:47 +00:00
import os
2023-05-19 14:01:33 +00:00
from os import environ
from pybuilder.core import task, init
from ddadevops import *
name = "buildtest"
MODULE = "release"
PROJECT_ROOT_PATH = "."
2024-01-26 11:10:18 +00:00
version = "1.8.10"
2023-05-19 14:01:33 +00:00
2024-01-26 09:29:26 +00:00
2023-05-19 14:01:33 +00:00
@init
def initialize(project):
input = {
"name": name,
"module": MODULE,
"stage": "notused",
"project_root_path": PROJECT_ROOT_PATH,
"build_types": [],
"mixin_types": ["RELEASE"],
2024-01-26 11:09:47 +00:00
"release_primary_build_file": "build_to_test.py",
"release_secondary_build_files": ["package.json", "project.clj", "build.gradle", "build.py"],
2023-09-22 10:26:48 +00:00
"release_artifacts": ["README.md"],
2023-08-17 06:46:22 +00:00
"release_artifact_server_url": "https://repo.prod.meissa.de",
"release_organisation": "meissa",
"release_repository_name": name,
2023-05-19 14:01:33 +00:00
}
project.build_depends_on("ddadevops>=4.10.7")
2024-01-26 11:09:47 +00:00
os.environ["RELEASE_ARTIFACT_TOKEN"] = "dummy"
2023-07-06 15:53:19 +00:00
build = ReleaseMixin(project, input)
2023-05-19 14:01:33 +00:00
build.initialize_build_dir()
2023-07-06 15:53:19 +00:00
@task
def patch(project):
2024-01-26 09:29:26 +00:00
"""
updates version to next patch level, creates a tag, creates new SNAPSHOT version,
commits primary build file (build.gradle) and pushes to remote
"""
2023-08-17 07:26:58 +00:00
linttest(project, "PATCH")
release(project)
2023-07-06 15:53:19 +00:00
2023-07-07 14:03:09 +00:00
2024-01-26 11:09:47 +00:00
@task
def increase_version_number(project):
prepare(project)
2023-07-06 15:53:19 +00:00
@task
def minor(project):
2024-01-26 09:29:26 +00:00
"""
updates version to next minor level, creates a tag, creates new SNAPSHOT version,
commits primary build file (build.gradle) and pushes to remote
"""
2023-08-17 07:26:58 +00:00
linttest(project, "MINOR")
release(project)
2023-07-06 15:53:19 +00:00
2023-07-07 14:03:09 +00:00
2023-07-06 15:53:19 +00:00
@task
def major(project):
2024-01-26 09:29:26 +00:00
"""
updates version to next major level, creates a tag, creates new SNAPSHOT version,
commits primary build file (build.gradle) and pushes to remote
"""
2023-08-17 07:26:58 +00:00
linttest(project, "MAJOR")
release(project)
2023-07-07 14:03:09 +00:00
2023-07-06 15:53:19 +00:00
@task
def dev(project):
2023-08-17 07:26:58 +00:00
linttest(project, "NONE")
2023-07-06 15:53:19 +00:00
2023-07-07 14:03:09 +00:00
2023-07-06 15:53:19 +00:00
@task
2023-08-17 07:26:58 +00:00
def prepare(project):
2023-05-19 14:01:33 +00:00
build = get_devops_build(project)
build.prepare_release()
2023-07-07 14:03:09 +00:00
2023-05-19 14:01:33 +00:00
@task
2023-08-17 07:26:58 +00:00
def tag(project):
2023-05-19 14:01:33 +00:00
build = get_devops_build(project)
build.tag_bump_and_push_release()
2023-07-06 15:53:19 +00:00
2023-08-17 06:46:22 +00:00
@task
def publish_artifacts(project):
2024-01-26 09:29:26 +00:00
""" creates a release in <release_artifact_server_url> and uploads artifacts """
2023-08-17 06:46:22 +00:00
build = get_devops_build(project)
2023-08-17 14:34:27 +00:00
print("PROTECTED_TOKEN_EXAMPLE" in environ)
print(environ.get("PROTECTED_TOKEN_EXAMPLE"))
2023-08-17 07:26:58 +00:00
build.publish_artifacts()
def release(project):
prepare(project)
tag(project)
def linttest(project, release_type):
build = get_devops_build(project)
build.update_release_type(release_type)