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
main
Georg Krause 2020-08-20 11:27:13 +02:00 committed by Agate
parent 294903245d
commit e329030ff1
3 changed files with 69 additions and 3 deletions

View File

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

View File

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

View File

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