Skip to content
Snippets Groups Projects
Commit bac22b0e authored by Laurens Oostwegel's avatar Laurens Oostwegel
Browse files

Support automatic builds and releases using Semantic Versioning

parent c23ba4dc
Branches
Tags
Loading
Checking pipeline status
...@@ -12,3 +12,5 @@ __pycache__ ...@@ -12,3 +12,5 @@ __pycache__
build build
dist dist
env env
taxonomylib/__version__.py
...@@ -8,6 +8,7 @@ cache: ...@@ -8,6 +8,7 @@ cache:
- .cache/pip - .cache/pip
- venv/ - venv/
.before_script: &test-before-script
before_script: before_script:
- python3 -V - python3 -V
- pip3 install virtualenv - pip3 install virtualenv
...@@ -16,11 +17,44 @@ before_script: ...@@ -16,11 +17,44 @@ before_script:
- pip3 install . - pip3 install .
- pip3 install .[tests] - pip3 install .[tests]
stages:
- tests
- release
linters: linters:
<<: *test-before-script
stage: tests
script: script:
- pip3 install .[linters] - pip3 install .[linters]
- make check - make check
tests: tests:
<<: *test-before-script
stage: tests
script: script:
- pytest tests - pytest tests
build:
stage: release
script:
- pip install --upgrade pip
- pip install setuptools setuptools_scm[toml] --upgrade
- pip install build twine
- python setup.py bdist_wheel
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url https://git.gfz-potsdam.de/api/v4/projects/2940/packages/pypi dist/*
only:
- tags
release_job:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
only:
- tags
script:
- echo "running release_job for $CI_COMMIT_TAG"
release:
tag_name: '$CI_COMMIT_TAG'
description: '$CI_COMMIT_TAG_MESSAGE'
ref: '$CI_COMMIT_SHA'
...@@ -9,7 +9,7 @@ in a controlled way. ...@@ -9,7 +9,7 @@ in a controlled way.
| Version | Description | | Version | Description |
|---------|-----------------------------------------------------------------------------------------------| |---------|-----------------------------------------------------------------------------------------------|
| 1.0 | Code used for the 2023.01 exposure data release. First published version of the taxonomy-lib. | | 1.0.0 | Code used for the 2023.01 exposure data release. First published version of the taxonomy-lib. |
## Copyright and copyleft ## Copyright and copyleft
......
# pyproject.toml
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
[tool.setuptools_scm]
write_to = "taxonomylib/__version__.py"
...@@ -23,7 +23,6 @@ linters_require = ["black>=20.8b1", "pylint", "flake8"] ...@@ -23,7 +23,6 @@ linters_require = ["black>=20.8b1", "pylint", "flake8"]
setup( setup(
name="taxonomylib", name="taxonomylib",
version="1.0",
description="Library for handling taxonomy strings", description="Library for handling taxonomy strings",
keywords="exposuremodel, building, taxonomylib, taxonomystring", keywords="exposuremodel, building, taxonomylib, taxonomystring",
author="Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ", author="Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ",
......
...@@ -17,5 +17,11 @@ ...@@ -17,5 +17,11 @@
# along with this program. If not, see http://www.gnu.org/licenses/. # along with this program. If not, see http://www.gnu.org/licenses/.
from .taxonomylib import Taxonomy from .taxonomylib import Taxonomy
from importlib.metadata import version, PackageNotFoundError
try:
__version__ = version("taxonomylib")
except PackageNotFoundError:
__version__ = "unknown version"
__all__ = ["Taxonomy"] __all__ = ["Taxonomy"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment