From e329030ff1026680b7179b01e203cb77abb12f4a Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Thu, 20 Aug 2020 11:27:13 +0200 Subject: [PATCH] Run build job only for master and tags Now that the setup script handles the correct version number we can use a single build job for stable and dev builds --- .gitlab-ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ setup.cfg | 10 ++++++++-- setup.py | 24 +++++++++++++++++++++++- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e385981..2614f31 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,7 @@ stages: - test + - build + - publish test: stage: test @@ -12,3 +14,39 @@ test: - pytest tags: - docker + +build: + stage: build + image: python:3 + before_script: + - apt-get update + - apt-get install libgirepository1.0-dev -y + - pip install .[build] + script: + - python3 setup.py sdist bdist_wheel + tags: + - docker + artifacts: + paths: + - dist/* + expire_in: 1 week + only: + - tags@funkwhale/mopidy + - master@funkwhale/mopidy + +publish: + stage: publish + image: python:3 + before_script: + - apt-get update + - apt-get install libgirepository1.0-dev -y + - pip install .[publish] + script: + - twine upload dist/* + tags: + - docker + dependencies: + - build + only: + - tags@funkwhale/mopidy + - master@funkwhale/mopidy diff --git a/setup.cfg b/setup.cfg index eae2432..888234a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,8 +1,7 @@ [metadata] name = mopidy_funkwhale description = "A backend extension for mopidy to stream music from a Funkwhale server" -version = 0.1.0 -author = Eliot Berriot +author = The Funkwhale Collective author_email = contact+funkwhale@eliotberriot.com url = https://dev.funkwhale.audio/funkwhale/mopidy long_description = file: README.rst @@ -40,6 +39,13 @@ dev = ipython ipdb +build = + setuptools + wheel + +publish = + twine + [options.packages.find] exclude = tests diff --git a/setup.py b/setup.py index 43deb57..3938606 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,27 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import codecs +import os from setuptools import setup -setup() +def read(rel_path): + here = os.path.abspath(os.path.dirname(__file__)) + with codecs.open(os.path.join(here, rel_path), 'r') as fp: + return fp.read() + +def get_version(): + tag = os.getenv('CI_COMMIT_TAG', None) + if tag: + return tag + + for line in read("mopidy_funkwhale/__init__.py").splitlines(): + if line.startswith('__version__'): + delim = '"' if '"' in line else "'" + version = line.split(delim)[1] + iid = os.getenv('CI_PIPELINE_IID', 0) + return "{}.dev{}".format(version, iid) + raise RuntimeError("Unable to find version string.") + +setup( + version=get_version(), +)