provs/build.py

142 lines
3.7 KiB
Python
Raw Normal View History

import os
2024-02-02 11:03:04 +00:00
from subprocess import run
from pybuilder.core import task, init
2023-08-08 07:43:28 +00:00
from ddadevops import *
name = "provs"
PROJECT_ROOT_PATH = "."
2024-10-04 21:57:15 +00:00
version = "0.38.3-dev"
@init
def initialize0(project):
"""
workaround to avoid prompt for gopass if no artifacts need to be uploaded
usage: with option "-E ng" , e.g. "pyb -E artifacts patch_local"
"""
os.environ["RELEASE_ARTIFACT_TOKEN"] = "dummy" # avoids prompt for RELEASE_ARTIFACT_TOKEN
@init(environments=["artifacts"])
def initialize1(project):
"""
2024-02-02 11:03:04 +00:00
prompt for gopass if artifacts need to be uploaded
usage: with option "-E artifacts" , e.g. "pyb -E artifacts dev"
"""
del os.environ["RELEASE_ARTIFACT_TOKEN"]
2023-08-08 07:43:28 +00:00
@init
2024-02-02 10:59:11 +00:00
def initialize2(project):
2023-08-08 07:43:28 +00:00
input = {
"name": name,
"module": "notused",
"stage": "notused",
"project_root_path": PROJECT_ROOT_PATH,
"build_types": [],
"mixin_types": ["RELEASE"],
2024-02-24 17:50:40 +00:00
"release_main_branch": "main",
2023-08-08 07:43:28 +00:00
"release_primary_build_file": "build.gradle",
"release_secondary_build_files": ["build.py"],
2023-11-24 22:10:02 +00:00
# release artifacts
"release_artifact_server_url": "https://repo.prod.meissa.de",
"release_organisation": "meissa",
"release_repository_name": name,
"release_artifacts": [
"build/libs/provs-server.jar",
"build/libs/provs-desktop.jar",
"build/libs/provs-syspec.jar",
"build/libs/sha256sum.lst",
"build/libs/sha512sum.lst",
],
2023-08-08 07:43:28 +00:00
}
2023-11-25 10:39:13 +00:00
build = ReleaseMixin(project, input)
build.initialize_build_dir()
2023-08-08 07:43:28 +00:00
@task
def dev(project):
"""
to avoid gopass prompt set RELEASE_ARTIFACT_TOKEN e.g.:
RELEASE_ARTIFACT_TOKEN=xxx pyb dev
"""
run("./gradlew assemble", shell=True)
2023-08-08 07:43:28 +00:00
@task
2023-11-24 22:10:02 +00:00
def build(project):
run("./gradlew assemble", shell=True)
2023-08-08 07:43:28 +00:00
@task
2023-11-24 22:10:02 +00:00
def patch(project):
"""
updates version to next patch level, creates a tag, creates new SNAPSHOT version,
2023-11-25 11:07:50 +00:00
commits primary build file (build.gradle) and pushes to remote
2023-11-24 22:10:02 +00:00
"""
increase_version_number(project, "PATCH")
2023-08-08 07:43:28 +00:00
release(project)
@task
2023-11-24 22:10:02 +00:00
def minor(project):
2023-11-25 11:07:50 +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-11-24 22:10:02 +00:00
increase_version_number(project, "MINOR")
release(project)
2023-08-08 07:43:28 +00:00
@task
2023-11-24 22:10:02 +00:00
def major(project):
2023-11-25 11:07:50 +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-11-24 22:10:02 +00:00
increase_version_number(project, "MAJOR")
release(project)
2023-08-08 07:43:28 +00:00
@task
def tag(project):
build = get_devops_build(project)
build.tag_bump_and_push_release()
2023-08-08 07:43:28 +00:00
@task
2023-11-24 22:10:02 +00:00
def release(project):
build = get_devops_build(project)
build.prepare_release()
tag(project)
2023-08-08 07:43:28 +00:00
@task
def package(project):
2023-11-24 22:10:02 +00:00
run("./gradlew assemble -x test jar", shell=True)
run("./gradlew assemble -x test uberjarDesktop", shell=True)
run("./gradlew assemble -x test uberjarServer", shell=True)
run("./gradlew assemble -x test uberjarSyspec", shell=True)
run("cd build/libs/ && find . -type f -exec sha256sum {} \; | sort > sha256sum.lst", shell=True)
run("cd build/libs/ && find . -type f -exec sha512sum {} \; | sort > sha512sum.lst", shell=True)
2023-11-24 22:10:02 +00:00
@task
def publish_release(project):
""" creates a release in repo.meissa and uploads artifacts (jar-files and checksum files) """
2023-11-24 22:10:02 +00:00
build = get_devops_build(project)
build.publish_artifacts()
2023-08-08 07:43:28 +00:00
2024-08-09 15:58:18 +00:00
@task
def inst(project):
run("./gradlew inst", shell=True)
2023-11-24 22:10:02 +00:00
def increase_version_number(project, release_type):
build = get_devops_build(project)
build.update_release_type(release_type)