Merge pull request 'master' (#3) from master into refactor-git-trust

Reviewed-on: #3
This commit is contained in:
zwa 2023-08-15 19:39:39 +00:00
commit 3f19ccd593
2 changed files with 102 additions and 34 deletions

View file

@ -1,5 +1,3 @@
image: openjdk:11-jdk-slim
stages:
- build
- test
@ -7,26 +5,34 @@ 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/ddadevops-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 ----------"
- ./gradlew assemble
- pyb build
artifacts:
paths:
- build/libs/*.jar
@ -60,6 +66,7 @@ test:
package:
<<: *kotlin
stage: package
script:
- ./gradlew -x assemble -x test jar
@ -76,22 +83,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 +104,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 +126,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

72
build.py Normal file
View file

@ -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)