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-02-02 10:27:05 +00:00
|
|
|
version = "4.0.1-dev"
|
2024-01-26 13:29:45 +00:00
|
|
|
|
|
|
|
|
2024-02-01 21:53:24 +00:00
|
|
|
@init
|
|
|
|
def initialize0(project):
|
2024-01-26 13:29:45 +00:00
|
|
|
"""
|
2024-01-26 13:39:23 +00:00
|
|
|
to avoid prompt for gopass if no artifacts need to be uploaded
|
2024-02-01 21:53:24 +00:00
|
|
|
usage: with option "-E ng" , e.g. "pyb -E artifacts patch_local"
|
2024-01-26 13:29:45 +00:00
|
|
|
"""
|
|
|
|
os.environ["RELEASE_ARTIFACT_TOKEN"] = "dummy" # avoids prompt for RELEASE_ARTIFACT_TOKEN
|
2023-05-19 14:01:33 +00:00
|
|
|
|
2024-02-02 07:38:54 +00:00
|
|
|
|
2024-02-01 21:53:24 +00:00
|
|
|
@init(environments=["artifacts"])
|
|
|
|
def initialize1(project):
|
|
|
|
"""
|
|
|
|
prompt for gopass if no artifacts need to be uploaded
|
|
|
|
usage: with option "-E artifacts" , e.g. "pyb -E artifacts patch_local"
|
|
|
|
"""
|
|
|
|
del os.environ["RELEASE_ARTIFACT_TOKEN"]
|
|
|
|
|
2024-01-26 09:29:26 +00:00
|
|
|
|
2023-05-19 14:01:33 +00:00
|
|
|
@init
|
2024-01-26 13:29:45 +00:00
|
|
|
def initialize2(project):
|
2023-05-19 14:01:33 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-01-12 09:56:55 +00:00
|
|
|
project.build_depends_on("ddadevops>=4.10.7")
|
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,
|
2024-01-26 13:32:42 +00:00
|
|
|
commits build files (primary and secondary) and pushes to remote
|
2024-01-26 09:29:26 +00:00
|
|
|
"""
|
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
|
2024-01-26 13:29:45 +00:00
|
|
|
def patch_local(project):
|
|
|
|
"""
|
|
|
|
updates version to next patch level,
|
2024-01-26 13:32:42 +00:00
|
|
|
commits build files (primary and secondary), DOES NOT push to remote
|
2024-01-26 13:29:45 +00:00
|
|
|
"""
|
|
|
|
linttest(project, "PATCH")
|
2024-01-26 11:09:47 +00:00
|
|
|
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,
|
2024-01-26 13:32:42 +00:00
|
|
|
commits build files (primary and secondary) and pushes to remote
|
2024-01-26 09:29:26 +00:00
|
|
|
"""
|
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,
|
2024-01-26 13:32:42 +00:00
|
|
|
commits build files (primary and secondary) and pushes to remote
|
2024-01-26 09:29:26 +00:00
|
|
|
"""
|
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)
|