Repository: halluxdev/hallux (language: python)

Issue:
Implement proper versioning
Version management need to be harmonised for the following tasks

1. python3 -m build  -- correct version created in the dist
2. pip install hallux==[version]  -- correct version installed
3. hallux --version  // correct version showed for installed package  
4. hallux.sh --version // correct version showed for dev package


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/hallux.yml b/.github/workflows/hallux.yml
index a2af71c..c2ccd2b 100644
--- a/.github/workflows/hallux.yml
+++ b/.github/workflows/hallux.yml
@@ -25,6 +25,8 @@ jobs:
       run: |
         export PATH=$(pwd)/bin:$PATH
         export PYTHONPATH=$(pwd)/hallux:${PYTHONPATH}
+        ./scripts/set-version.sh
+
         python -m pytest \
           --cov-branch \
           --cov-report=term \
diff --git a/.gitignore b/.gitignore
index 0e23ff9..e7a42c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,6 @@ htmlcov/
 .DS_Store
 dummy.json
 # this file is auto-generated
-src/__version__.py
+hallux/VERSION
 dist
 **/hallux.egg-info
diff --git a/docs/dev-guide/versioning.md b/docs/dev-guide/versioning.md
new file mode 100644
index 0000000..7999ec1
--- /dev/null
+++ b/docs/dev-guide/versioning.md
@@ -0,0 +1,30 @@
+# Versioning
+
+Hallux follows [PEP 440](https://peps.python.org/pep-0440/) versioning scheme composed from git tag and the distance. 
+
+For example:
+
+- git tag: 0.2
+- distance: 10 commits since tag
+- version: 0.2.10
+
+## Tagging
+
+Currently tagging is a manual process decided by maintainers based on development milestones.
+
+```bash
+git tag -a -m "Introduce tag versioning" 0.2
+git push origin --tags
+```
+
+## Publishing a new version
+
+Currently publishing a new version to a PyPI registry is a manual process decided by maintainers based on development milestones.
+
+```bash
+# Build source distribution
+./scripts/build-package.sh
+
+# Publish to PyPI
+python3 -m twine upload --repository pypi dist/*
+```
diff --git a/hallux/VERSION b/hallux/VERSION
deleted file mode 100644
index f5ca63c..0000000
--- a/hallux/VERSION
+++ /dev/null
@@ -1,1 +0,0 @@
-0.2.200
\ No newline at end of file
diff --git a/scripts/build-package.sh b/scripts/build-package.sh
new file mode 100755
index 0000000..0c0cf84
--- /dev/null
+++ b/scripts/build-package.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+cd "${0%/*}/.."
+
+rm -rf dist/*
+
+./scripts/set-version.sh
+
+python3 -m build
diff --git a/scripts/set-version.sh b/scripts/set-version.sh
new file mode 100755
index 0000000..4683238
--- /dev/null
+++ b/scripts/set-version.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+cd "${0%/*}/.."
+
+# Relies on the git tag
+MAJOR=$(git describe --long | awk -F "-" '{print $1}')
+DISTANCE=$(git describe --long | awk -F "-" '{print $2}')
+VERSION=${MAJOR}.${DISTANCE}
+
+echo -n ${VERSION} > hallux/VERSION;
diff --git a/scripts/sonar-scanner.sh b/scripts/sonar-scanner.sh
index 27a10f4..9e90618 100755
--- a/scripts/sonar-scanner.sh
+++ b/scripts/sonar-scanner.sh
@@ -4,8 +4,6 @@ source ./activate.sh
 
 ./hallux-test.sh -x
 
-MAJOR=$(cat hallux/VERSION)
-
-VERSION="${MAJOR}.$(git rev-list --count HEAD)-$(git rev-parse --short HEAD)"
+VERSION="$(git describe --long)"
 
 sonar-scanner -Dsonar.host.url=https://sonarqube.hallux.dev -Dsonar.token=${SONARQUBE_TOKEN} -Dsonar.projectVersion="${VERSION}"
\ No newline at end of file


Test patch:
diff --git a/hallux-test.sh b/hallux-test.sh
index b5017ac..6434b4e 100755
--- a/hallux-test.sh
+++ b/hallux-test.sh
@@ -1,13 +1,13 @@
 #!/usr/bin/env bash
 
 source ./activate.sh
+./scripts/set-version.sh
 
 python -m pytest -v $1 $2\
     --cov-branch \
     --cov-report=term \
-    --cov=src \
+    --cov=hallux \
     --cov-report=xml \
     --cov-report=html \
     --junitxml xunit-reports/xunit-result-unit.xml \
-    tests/integration \
     tests/unit || exit 1