Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Merge pull request #80 from zalando-stups/build-with-cdp
Browse files Browse the repository at this point in the history
Build with CDP
  • Loading branch information
aermakov-zalando authored Jan 4, 2019
2 parents 5fdd8af + 5988053 commit ea3efd5
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 2,212 deletions.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Hack to upload version to Pypi

FROM registry.opensource.zalan.do/stups/python AS builder
ARG VERSION
RUN apt-get update && \
apt-get install -q -y python3-pip && \
pip3 install -U tox setuptools
COPY . /build
WORKDIR /build
RUN sed -i "s/__version__ = .*/__version__ = '${VERSION}'/" */__init__.py
RUN python3 setup.py sdist bdist_wheel

FROM pierone.stups.zalan.do/teapot/python-cdp-release:latest
COPY --from=builder /build/dist /pydist
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ include *.txt
include *.rst
recursive-include sevenseconds *.py
recursive-include docs *.rst *.py
include versioneer.py
include sevenseconds/_version.py
34 changes: 34 additions & 0 deletions delivery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "2017-09-20"
pipeline:
- id: build
type: script
overlay: ci/python
commands:
- desc: "Install dependencies"
cmd: |
pip install -r requirements.txt
pip install coveralls codecov
- desc: "Run Tests"
cmd: python3 setup.py test
- desc: "Check code style"
cmd: python3 setup.py flake8
- desc: "Build docker image that will upload package"
cmd: |
VERSION=$(./next-version)
if [[ -z "${CDP_PULL_REQUEST_NUMBER}" ]]; then
DOCKER_IMAGE="pierone.stups.zalan.do/teapot/sevenseconds-release:${CDP_TARGET_REPOSITORY_COUNTER}"
else
DOCKER_IMAGE="pierone.stups.zalan.do/teapot/sevenseconds-release-pr:${CDP_TARGET_REPOSITORY_COUNTER}"
fi
docker build --build-arg VERSION="$VERSION" -t "$DOCKER_IMAGE" .
docker push "$DOCKER_IMAGE"
if [[ -z "${CDP_PULL_REQUEST_NUMBER}" ]]; then
git log -1 --pretty=%B > CHANGELOG
# TODO upload the wheel package
git gh-release --message-from-file CHANGELOG $VERSION
fi
# The actual release is done by a pipeline in Zalando's Internal Github Enterprise
30 changes: 30 additions & 0 deletions next-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3

import subprocess

MAJOR_VERSION = 1
MINOR_VERSION = 2


def get_latest_version() -> (int, int, int):
"""
Gets latest version based on Git Tags.
"""
proc = subprocess.run(['git', 'tag'], stdout=subprocess.PIPE)

versions = sorted(map(lambda version: tuple(int(sub)
for sub
in version.split('.')),
proc.stdout.decode().splitlines()))
return versions[-1]


if __name__ == '__main__':
major, minor, build = get_latest_version()

if major != MAJOR_VERSION or minor != MINOR_VERSION:
new_build = 0
else:
new_build = build + 1

print(f"{MAJOR_VERSION}.{MINOR_VERSION}.{new_build}")
34 changes: 0 additions & 34 deletions release.sh

This file was deleted.

8 changes: 0 additions & 8 deletions setup.cfg

This file was deleted.

16 changes: 10 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import inspect
from distutils.cmd import Command

import versioneer
import setuptools
from setuptools.command.test import test as TestCommand
from setuptools import setup
Expand All @@ -22,9 +21,16 @@
__location__ = os.path.join(os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe())))


def read_version(package):
data = {}
with open(os.path.join(package, '__init__.py'), 'r') as fd:
exec(fd.read(), data)
return data['__version__']


NAME = 'stups-sevenseconds'
MAIN_PACKAGE = 'sevenseconds'
VERSION = versioneer.get_version()
VERSION = read_version(MAIN_PACKAGE)
DESCRIPTION = 'Configure AWS accounts'
LICENSE = 'Apache License 2.0'
URL = 'https://github.com/zalando-stups/sevenseconds'
Expand All @@ -35,6 +41,7 @@
COVERAGE_HTML = False
JUNIT_XML = False


# Add here all kinds of additional classifiers as defined under
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
CLASSIFIERS = [
Expand Down Expand Up @@ -153,10 +160,7 @@ def read(fname):


def setup_package():
# Assemble additional setup commands
cmdclass = versioneer.get_cmdclass()
cmdclass['docs'] = sphinx_builder()
cmdclass['doctest'] = sphinx_builder()
cmdclass = {}
cmdclass['test'] = PyTest

docs_path = os.path.join(__location__, 'docs')
Expand Down
4 changes: 1 addition & 3 deletions sevenseconds/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
__version__ = '0.0.1'
Loading

0 comments on commit ea3efd5

Please sign in to comment.