Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version handling #198

Merged
merged 25 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
40d141b
Add packaging as direct dependency
bjoernricks Mar 31, 2020
e5ffa9e
Use a PEP 440 compliant version string
bjoernricks Mar 31, 2020
e2f9a99
Add own function to convert to a PEP 440 compliant version
bjoernricks Mar 31, 2020
45e9e54
Move get_version_from_pyproject_toml func to utils
bjoernricks Mar 31, 2020
a7198d0
Hardcode version in __version__.py
bjoernricks Mar 31, 2020
ff3f100
Add utility to handle version information
bjoernricks Mar 31, 2020
af691c1
Move version script into gvm package
bjoernricks Mar 31, 2020
5b5d04b
Move version functions from utils to version module
bjoernricks Mar 31, 2020
9290ae0
Refactor version checks into several function
bjoernricks Apr 1, 2020
3ed3a9b
Update and move get_version_string test module
bjoernricks Apr 1, 2020
c4a6284
Add docstring for strip_version function
bjoernricks Apr 1, 2020
1916abf
Add testcase for strip_version function
bjoernricks Apr 1, 2020
66619e5
Add testcase for safe_version function
bjoernricks Apr 1, 2020
bfc79d1
Add testcase for get_version_from_pyproject_toml
bjoernricks Apr 1, 2020
4fe7372
Add testcase for check_version_equal function
bjoernricks Apr 1, 2020
362cc09
Rename function and add testcase
bjoernricks Apr 1, 2020
2a61101
Add testcase for update_version_file function
bjoernricks Apr 1, 2020
86750e5
Remove extra spaces
bjoernricks Apr 1, 2020
0c88830
Add an additional test for different dev versions
bjoernricks Apr 1, 2020
75a11ed
Replace toml with tomlkit
bjoernricks Apr 1, 2020
8866034
Don't call poetry for a version update
bjoernricks Apr 1, 2020
043331d
Fix checking for equal version when updating the version
bjoernricks Apr 1, 2020
df23dea
Rename check_version_equal to versions_equal
bjoernricks Apr 1, 2020
1c42bab
Update RELEASE doc for new version handling
bjoernricks Apr 1, 2020
9ce9410
Add changelog entry for new version handling
bjoernricks Apr 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ commands:
- run:
name: Check with pylint
command: poetry run pylint --disable=R gvm
- run:
name: Check version information
command: poetry run python -m gvm.version verify current
deploy:
description: "Upload package to PyPI"
steps:
Expand All @@ -70,7 +73,7 @@ commands:
command: poetry install --no-dev
- run:
name: Verify tag version
command: poetry run python verify-version.py ${CIRCLE_TAG}
command: poetry run python -m gvm.version verify ${CIRCLE_TAG}
- run:
name: Install twine
command: poetry run pip install twine
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Added
* Added an API and CLI utilities for the version handling in python-gvm
[#198](https://github.com/greenbone/python-gvm/pull/198)

### Changed
- Replaced `pipenv` with `poetry` for dependency management. `poetry install`
* Replaced `pipenv` with `poetry` for dependency management. `poetry install`
works a bit different then `pipenv install`. It installs dev packages by
default and also python-gvm in editable mode. This means after running
`poetry install` gvm will directly be importable in the virtual python
Expand Down
20 changes: 17 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,23 @@ release. We are following [Semantic Versioning](https://semver.org/) and
git checkout -b create-new-release upstream/master
```

* Open `pyproject.toml` and increment the version number. For example, if the
file contains `version = 22.4dev1`, the line should be changed to
`version = 22.4`.
* Get the current version number

```sh
poetry run python -m gvm.version show
```

* Determine new release version number

If the output is something like `22.4.dev1` or `21.10a1`, the new version
should be `22.4` or `21.10` respectively.

* Update to new version number (`<new-version>` must be replaced by the version
from the last step)

```sh
poetry run python -m gvm.version update <new-version>
```

* Update the `CHANGELOG.md` file:
* Change `[unreleased]` to new release version.
Expand Down
21 changes: 2 additions & 19 deletions gvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,7 @@
"""
Main module of python-gvm.
"""
from pathlib import Path

from pkg_resources import safe_version

import toml


def get_version_from_pyproject_toml() -> str:
path = Path(__file__)
pyproject_toml_path = path.parent.parent / 'pyproject.toml'

if pyproject_toml_path.exists():
pyproject_toml = toml.loads(pyproject_toml_path.read_text())
if 'tool' in pyproject_toml and 'poetry' in pyproject_toml['tool']:
return pyproject_toml['tool']['poetry']['version']

raise RuntimeError('Version information not found in pyproject.toml file.')
from .__version__ import __version__


def get_version() -> str:
Expand All @@ -47,5 +31,4 @@ def get_version() -> str:
.. _PEP440:
https://www.python.org/dev/peps/pep-0440
"""
str_version = get_version_from_pyproject_toml()
return safe_version(str_version)
return __version__
5 changes: 5 additions & 0 deletions gvm/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# pylint: disable=invalid-name

# THIS IS AN AUTOGENERATED FILE. DO NOT TOUCH!

__version__ = "20.4.dev1"
24 changes: 1 addition & 23 deletions gvm/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018 - 2019 Greenbone Networks GmbH
# Copyright (C) 2018 - 2020 Greenbone Networks GmbH
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
Expand All @@ -21,25 +21,3 @@

def deprecation(message: str):
warnings.warn(message, DeprecationWarning, stacklevel=2)


def get_version_string(version: tuple) -> str:
"""Create a version string from a version tuple

Arguments:
version: version as tuple e.g. (1, 2, 0, dev, 5)

Returns:
The version tuple converted into a string representation
"""
if len(version) > 4:
ver = ".".join(str(x) for x in version[:4])
ver += str(version[4])

if len(version) > 5:
# support (1, 2, 3, 'beta', 2, 'dev', 1)
ver += ".{0}{1}".format(str(version[5]), str(version[6]))

return ver
else:
return ".".join(str(x) for x in version)
Loading