diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml
index c7ff8edc..4d253eb5 100644
--- a/.github/workflows/publish-to-pypi.yml
+++ b/.github/workflows/publish-to-pypi.yml
@@ -1,14 +1,17 @@
-name: Publish PyPI and TestPyPI
+name: Publish PyPI
 
 on:
   push:
-    branches: [ unstable ]
+    tags:
+      - '[0-9]+.[0-9]+.[0-9]+'
+      - '[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
 
 jobs:
   build:
     name: Build distribution 📦
     runs-on: ubuntu-latest
     container:   # we have to provide a working triqs installation to make the cmake step work
+      # image: materialstheory/solid_dmft_ci:${{github.ref_name}}
       image: materialstheory/solid_dmft_ci
 
     steps:
@@ -25,9 +28,9 @@ jobs:
         --user
     - name: prepare python distribution
       run: |
-        cp packaging/pypi/* ./
         mkdir build && cd build 
         cmake ../
+        cp packaging/pypi/* ../
         mv python/solid_dmft/version.py ../python/solid_dmft/version.py
         rm ../python/solid_dmft/version.py.in
     - name: Build a binary wheel and a source tarball
@@ -39,8 +42,7 @@ jobs:
         path: dist/
 
   publish-to-pypi:
-    name: Publish to PyPI 🐍
-    if: startsWith(github.ref, 'refs/tags/')  # only publish to PyPI on tag pushes
+    name: Publish PyPI 🐍
     needs:
     - build
     runs-on: ubuntu-latest
@@ -61,27 +63,3 @@ jobs:
       with:
         skip-existing: true # skip if version name package already exists on pypi
 
-  publish-to-testpypi:
-    name: Publish to TestPyPI 🐍
-    needs:
-    - build
-    runs-on: ubuntu-latest
-
-    environment:
-      name: pypi
-      url: https://test.pypi.org/p/solid_dmft
-
-    permissions:
-      id-token: write  # IMPORTANT: mandatory for trusted publishing
-
-    steps:
-    - name: Download all the dists
-      uses: actions/download-artifact@v3
-      with:
-        name: python-package-distributions
-        path: dist/
-    - name: Publish distribution 📦 to TestPyPI
-      uses: pypa/gh-action-pypi-publish@release/v1
-      with:
-        skip-existing: true # skip if version name package already exists on pypi
-        repository-url: https://test.pypi.org/legacy/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ebd07fe0..bd3353dd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,6 +109,9 @@ add_subdirectory(share)
 # executable
 add_subdirectory(bin)            # Executables
 
+# packaging versions
+add_subdirectory(packaging)
+
 # #############
 # Debian Package
 
diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt
new file mode 100644
index 00000000..08fd881f
--- /dev/null
+++ b/packaging/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Configure the version of packaging files
+configure_file(conda/meta.yaml.in conda/meta.yaml)
+configure_file(pypi/MANIFEST.in pypi/MANIFEST.in COPYONLY)
+configure_file(pypi/pyproject.toml.in pypi/pyproject.toml)
+configure_file(solid_dmft-foss-2021b.eb.in solid_dmft-foss-2021b.eb)
+
+
diff --git a/packaging/conda/meta.yaml b/packaging/conda/meta.yaml.in
similarity index 96%
rename from packaging/conda/meta.yaml
rename to packaging/conda/meta.yaml.in
index 0a26d142..ec7f1be8 100644
--- a/packaging/conda/meta.yaml
+++ b/packaging/conda/meta.yaml.in
@@ -1,4 +1,4 @@
-{% set version = "3.2.0" %}
+{% set version = "@PROJECT_VERSION@" %}
 
 package:
   name: solid_dmft
diff --git a/packaging/pypi/pyproject.toml b/packaging/pypi/pyproject.toml.in
similarity index 96%
rename from packaging/pypi/pyproject.toml
rename to packaging/pypi/pyproject.toml.in
index 9d0ec282..ec88af59 100644
--- a/packaging/pypi/pyproject.toml
+++ b/packaging/pypi/pyproject.toml.in
@@ -7,7 +7,7 @@ where = ["python"]
 
 [project]
 name = "solid_dmft"
-version = "3.2.0"
+version = "@PROJECT_VERSION@"
 authors = [
   { name="Alexander Hampel", email="ahampel@flatironinstitute.org" }
 ]
diff --git a/packaging/solid_dmft-3.2.0-foss-2021b.eb b/packaging/solid_dmft-foss-2021b.eb.in
similarity index 97%
rename from packaging/solid_dmft-3.2.0-foss-2021b.eb
rename to packaging/solid_dmft-foss-2021b.eb.in
index f9b95ee9..8cff2166 100644
--- a/packaging/solid_dmft-3.2.0-foss-2021b.eb
+++ b/packaging/solid_dmft-foss-2021b.eb.in
@@ -1,7 +1,7 @@
 easyblock = 'CMakeMake'
 
 name = 'solid_dmft'
-version = '3.2.0'
+version = '@PROJECT_VERSION@'
 
 homepage = 'https://triqs.github.io/solid_dmft/'
 description = """