Updated ddadevops
This commit is contained in:
parent
ddd004c6ad
commit
31ba0427b0
6 changed files with 117 additions and 62 deletions
|
@ -3,13 +3,27 @@ stages:
|
||||||
- test
|
- test
|
||||||
- publish
|
- publish
|
||||||
|
|
||||||
|
.img: &img
|
||||||
|
image: "domaindrivenarchitecture/ddadevops-dind:4.7.2"
|
||||||
services:
|
services:
|
||||||
- docker:19.03.12-dind
|
- docker:dind
|
||||||
|
before_script:
|
||||||
|
- export RELEASE_ARTIFACT_TOKEN=$MEISSA_REPO_BUERO_RW
|
||||||
|
- export IMAGE_DOCKERHUB_USER=$DOCKERHUB_USER
|
||||||
|
- export IMAGE_DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD
|
||||||
|
- export IMAGE_TAG=$CI_COMMIT_TAG
|
||||||
|
|
||||||
build:
|
.tag_only: &tag_only
|
||||||
image: domaindrivenarchitecture/devops-build:latest
|
|
||||||
stage: build
|
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_TAG != null'
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||||
|
when: never
|
||||||
|
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
|
||||||
|
|
||||||
|
dda-backup-image-publish:
|
||||||
|
<<: *img
|
||||||
|
<<: *tag_only
|
||||||
|
stage: image
|
||||||
script:
|
script:
|
||||||
- cd infrastructure/docker && pyb image test publish
|
- cd infrastructure/docker && pyb image publish
|
||||||
|
|
||||||
|
|
||||||
|
|
74
build.py
Normal file
74
build.py
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
from os import environ
|
||||||
|
from subprocess import run
|
||||||
|
from pybuilder.core import init, task
|
||||||
|
from ddadevops import *
|
||||||
|
|
||||||
|
default_task = "dev"
|
||||||
|
|
||||||
|
name = "dda-backup"
|
||||||
|
MODULE = "not-used"
|
||||||
|
PROJECT_ROOT_PATH = "."
|
||||||
|
|
||||||
|
|
||||||
|
@init
|
||||||
|
def initialize(project):
|
||||||
|
input = {
|
||||||
|
"name": name,
|
||||||
|
"module": MODULE,
|
||||||
|
"stage": "notused",
|
||||||
|
"project_root_path": PROJECT_ROOT_PATH,
|
||||||
|
"build_types": [],
|
||||||
|
"mixin_types": ["RELEASE"],
|
||||||
|
"release_primary_build_file": "build.py",
|
||||||
|
"release_secondary_build_files": [
|
||||||
|
"infrastructure/docker/build.py"
|
||||||
|
],
|
||||||
|
"release_artifact_server_url": "https://repo.prod.meissa.de",
|
||||||
|
"release_organisation": "meissa",
|
||||||
|
"release_repository_name": name,
|
||||||
|
"release_artifacts": [],
|
||||||
|
}
|
||||||
|
|
||||||
|
build = ReleaseMixin(project, input)
|
||||||
|
build.initialize_build_dir()
|
||||||
|
|
||||||
|
@task
|
||||||
|
def patch(project):
|
||||||
|
build = get_devops_build(project)
|
||||||
|
build.update_release_type("PATCH")
|
||||||
|
release(project)
|
||||||
|
|
||||||
|
|
||||||
|
@task
|
||||||
|
def minor(project):
|
||||||
|
build = get_devops_build(project)
|
||||||
|
build.update_release_type("MINOR")
|
||||||
|
release(project)
|
||||||
|
|
||||||
|
|
||||||
|
@task
|
||||||
|
def major(project):
|
||||||
|
build = get_devops_build(project)
|
||||||
|
build.update_release_type("MAJOR")
|
||||||
|
release(project)
|
||||||
|
|
||||||
|
|
||||||
|
@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 publish_artifacts(project):
|
||||||
|
build = get_devops_build(project)
|
||||||
|
build.publish_artifacts()
|
||||||
|
|
||||||
|
def release(project):
|
||||||
|
prepare(project)
|
||||||
|
tag(project)
|
|
@ -1 +0,0 @@
|
||||||
VERSION=1.0.8 $@
|
|
|
@ -1,11 +0,0 @@
|
||||||
# stable release (should be done from master)
|
|
||||||
|
|
||||||
1. Test if image build, image test and image publish is working:
|
|
||||||
```
|
|
||||||
cd infrastructure/docker && pyb image test publish
|
|
||||||
```
|
|
||||||
|
|
||||||
2. If image, test & publish is working, you can run the release script in the project root:
|
|
||||||
```
|
|
||||||
./release.sh
|
|
||||||
```
|
|
|
@ -1,32 +1,35 @@
|
||||||
from os import environ
|
from os import environ
|
||||||
|
from datetime import datetime
|
||||||
from pybuilder.core import task, init
|
from pybuilder.core import task, init
|
||||||
from ddadevops import *
|
from ddadevops import *
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
name = 'dda-backup'
|
name = 'dda-backup'
|
||||||
MODULE = 'docker'
|
MODULE = 'NOT_SET'
|
||||||
PROJECT_ROOT_PATH = '../..'
|
PROJECT_ROOT_PATH = '../..'
|
||||||
|
version = "1.0.9-SNAPSHOT"
|
||||||
|
|
||||||
|
|
||||||
class MyBuild(DevopsDockerBuild):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@init
|
@init
|
||||||
def initialize(project):
|
def initialize(project):
|
||||||
project.build_depends_on('ddadevops>=0.12.4')
|
image_tag = version
|
||||||
stage = 'notused'
|
if "dev" in image_tag:
|
||||||
dockerhub_user = environ.get('DOCKERHUB_USER')
|
image_tag += datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
|
||||||
if not dockerhub_user:
|
|
||||||
dockerhub_user = gopass_field_from_path('meissa/web/docker.com', 'login')
|
input = {
|
||||||
dockerhub_password = environ.get('DOCKERHUB_PASSWORD')
|
"name": name,
|
||||||
if not dockerhub_password:
|
"module": MODULE,
|
||||||
dockerhub_password = gopass_password_from_path('meissa/web/docker.com')
|
"stage": "notused",
|
||||||
tag = environ.get('CI_COMMIT_TAG')
|
"project_root_path": PROJECT_ROOT_PATH,
|
||||||
if not tag:
|
"build_types": ["IMAGE"],
|
||||||
tag = get_tag_from_latest_commit()
|
"mixin_types": [],
|
||||||
config = create_devops_docker_build_config(
|
"image_naming": "NAME_ONLY",
|
||||||
stage, PROJECT_ROOT_PATH, MODULE, dockerhub_user, dockerhub_password, docker_publish_tag=tag)
|
"image_tag": f"{image_tag}",
|
||||||
build = MyBuild(project, config)
|
}
|
||||||
|
|
||||||
|
project.build_depends_on("ddadevops>=4.7.0")
|
||||||
|
|
||||||
|
build = DevopsImageBuild(project, input)
|
||||||
build.initialize_build_dir()
|
build.initialize_build_dir()
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,13 +43,9 @@ def drun(project):
|
||||||
build = get_devops_build(project)
|
build = get_devops_build(project)
|
||||||
build.drun()
|
build.drun()
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def publish(project):
|
def publish(project):
|
||||||
build = get_devops_build(project)
|
build = get_devops_build(project)
|
||||||
build.dockerhub_login()
|
build.dockerhub_login()
|
||||||
build.dockerhub_publish()
|
build.dockerhub_publish()
|
||||||
|
|
||||||
@task
|
|
||||||
def test(project):
|
|
||||||
build = get_devops_build(project)
|
|
||||||
build.test()
|
|
||||||
|
|
20
release.sh
20
release.sh
|
@ -1,20 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
source development-version.sh
|
|
||||||
|
|
||||||
if [ -z "$VERSION" ]
|
|
||||||
then
|
|
||||||
echo "Error: VERSION needs to be set!"
|
|
||||||
else
|
|
||||||
git pull
|
|
||||||
echo "Release version: $VERSION"
|
|
||||||
|
|
||||||
while IFS='.' read -ra NUM; do
|
|
||||||
echo "VERSION=${NUM[0]}.${NUM[1]}.$((NUM[2]+1)) \$@" > development-version.sh
|
|
||||||
done <<< "$VERSION"
|
|
||||||
echo "Version bumped in file 'development-version.sh'"
|
|
||||||
|
|
||||||
git add -A && git commit -m "Version ${VERSION}"
|
|
||||||
git tag -a ${VERSION} -m "Release ${VERSION}"
|
|
||||||
git push --follow-tags
|
|
||||||
fi
|
|
Loading…
Reference in a new issue