From a8b8c4e4db5123d998d0d8da402088f15659b312 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Tue, 8 Aug 2023 09:18:10 +0200 Subject: [PATCH 1/4] introduce new kind of ci --- .gitlab-ci.yml | 61 ++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 695f08e..24417fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,3 @@ -image: openjdk:11-jdk-slim - stages: - build - test @@ -7,22 +5,31 @@ stages: - publish - release -before_script: - - echo "---------- Start CI ----------" - - export GRADLE_USER_HOME=`pwd`/.gradle - - chmod +x gradlew - - echo "------ commit info ---------------" - - echo $CI_COMMIT_TAG - - echo $CI_COMMIT_REF_NAME - - echo "----------------------------------" +.kotlin-job: &kotlin + image: domaindrivenarchitecture/shadow-kotlin + cache: + key: ${CI_COMMIT_REF_SLUG} + paths: + - .gradle/wrapper + - .gradle/caches + before_script: + - echo "---------- Start CI ----------" + - export GRADLE_USER_HOME=`pwd`/.gradle + - chmod +x gradlew + - echo "------ commit info ---------------" + - echo $CI_COMMIT_TAG + - echo $CI_COMMIT_REF_NAME + - echo "----------------------------------" -cache: - paths: - - .gradle/wrapper - - .gradle/caches +.tag_only: &tag_only + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + when: never + - if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/' build: + <<: *kotlin stage: build script: - echo "---------- build stage ----------" @@ -60,6 +67,7 @@ test: package: + <<: *kotlin stage: package script: - ./gradlew -x assemble -x test jar @@ -76,22 +84,18 @@ package: publish-maven-package-to-gitlab: + <<: *kotlin + <<: *tag_only stage: publish - rules: - - if: $CI_PIPELINE_SOURCE != "push" - when: never - - if: $CI_COMMIT_TAG !~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/ script: - ./gradlew -x assemble -x test publishLibraryPublicationToGitlabRepository publish-maven-package-to-meissa: + <<: *kotlin + <<: *tag_only stage: publish allow_failure: true - rules: - - if: $CI_PIPELINE_SOURCE != "push" - when: never - - if: $CI_COMMIT_TAG !~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/ script: - apt-get update -y - apt-get install -y iputils-ping ssh @@ -101,12 +105,9 @@ publish-maven-package-to-meissa: release-to-gitlab: + <<: *tag_only image: registry.gitlab.com/gitlab-org/release-cli:latest stage: release - rules: - - if: $CI_PIPELINE_SOURCE != "push" - when: never - - if: $CI_COMMIT_TAG =~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/ artifacts: paths: - 'build/libs/provs-desktop.jar' @@ -126,15 +127,11 @@ release-to-gitlab: release-to-meissa: + <<: *kotlin + <<: *tag_only stage: release allow_failure: true - rules: - - if: $CI_PIPELINE_SOURCE != "push" - when: never - - if: $CI_COMMIT_TAG =~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/ script: - - apt-get update - - apt-get -yqq install curl - ./gradlew createReleaseAndUploadAssets -- 2.45.2 From 3a82fc707b861273e630cb8c739b5900fcedddb8 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Tue, 8 Aug 2023 09:20:41 +0200 Subject: [PATCH 2/4] introduce new kind of ci --- .gitlab-ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 24417fd..7f1c5b1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,14 +12,14 @@ stages: paths: - .gradle/wrapper - .gradle/caches - before_script: - - echo "---------- Start CI ----------" - - export GRADLE_USER_HOME=`pwd`/.gradle - - chmod +x gradlew - - echo "------ commit info ---------------" - - echo $CI_COMMIT_TAG - - echo $CI_COMMIT_REF_NAME - - echo "----------------------------------" + before_script: + - echo "---------- Start CI ----------" + - export GRADLE_USER_HOME=`pwd`/.gradle + - chmod +x gradlew + - echo "------ commit info ---------------" + - echo $CI_COMMIT_TAG + - echo $CI_COMMIT_REF_NAME + - echo "----------------------------------" .tag_only: &tag_only rules: -- 2.45.2 From e4e635d45b4884c8e8cd3e4aaa07f8d334fcf107 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Tue, 8 Aug 2023 09:22:36 +0200 Subject: [PATCH 3/4] introduce new kind of ci --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7f1c5b1..c3f1e6e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ stages: - release .kotlin-job: &kotlin - image: domaindrivenarchitecture/shadow-kotlin + image: domaindrivenarchitecture/ddadevops-kotlin cache: key: ${CI_COMMIT_REF_SLUG} paths: -- 2.45.2 From c1267ac17ea8142f0a88e5be057ea2b22bfce507 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Tue, 8 Aug 2023 09:43:28 +0200 Subject: [PATCH 4/4] use pyb --- .gitlab-ci.yml | 3 +-- build.py | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 build.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c3f1e6e..e773745 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,8 +32,7 @@ build: <<: *kotlin stage: build script: - - echo "---------- build stage ----------" - - ./gradlew assemble + - pyb build artifacts: paths: - build/libs/*.jar diff --git a/build.py b/build.py new file mode 100644 index 0000000..b06edd4 --- /dev/null +++ b/build.py @@ -0,0 +1,72 @@ +from os import environ +from subprocess import run +from pybuilder.core import init, task +from ddadevops import * + +default_task = "dev" + +name = "provs" +PROJECT_ROOT_PATH = "." + + +@init +def initialize(project): + input = { + "name": name, + "module": "notused", + "stage": "notused", + "project_root_path": PROJECT_ROOT_PATH, + "build_types": [], + "mixin_types": ["RELEASE"], + "release_primary_build_file": "build.gradle", + "release_secondary_build_files": [], + } + + build = ReleaseMixin(project, input) + build.initialize_build_dir() + +@task +def patch(project): + linttest(project, "PATCH") + release(project) + + +@task +def minor(project): + linttest(project, "MINOR") + release(project) + + +@task +def major(project): + linttest(project, "MAJOR") + release(project) + + +@task +def dev(project): + linttest(project, "NONE") + + +@task +def prepare(project): + build = get_devops_build(project) + build.prepare_release() + + +@task +def tag(project): + build = get_devops_build(project) + build.tag_bump_and_push_release() + +@task +def build(project): + print("---------- build stage ----------") + run("./gradlew assemble", shell=True) + +def release(project): + prepare(project) + tag(project) + +def linttest(project, release_type): + build(project) \ No newline at end of file -- 2.45.2