From 27defb11564ef9010c55e11367a6417f2d81d82d Mon Sep 17 00:00:00 2001 From: Marvin Klerx Date: Thu, 10 Sep 2026 22:44:21 +0200 Subject: [PATCH] changed release creation process --- .github/workflows/release.yml | 4 ++++ .gitignore | 1 + DEVELOPMENT.md | 34 +++++++++++++--------------------- create_release.sh | 32 ++++++++++++++++---------------- pyproject.toml | 9 ++++++--- src/Tables/__about__.py | 4 ---- src/Tables/__init__.py | 2 +- 7 files changed, 41 insertions(+), 45 deletions(-) delete mode 100644 src/Tables/__about__.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 431e5809..3fbf1dee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,6 +14,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Create GitHub Release uses: softprops/action-gh-release@v2 @@ -31,6 +33,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v5 diff --git a/.gitignore b/.gitignore index 34d0a414..391e0dc8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ __pycache__/ # Distribution / packaging .Python build/ +src/Tables/_version.py develop-eggs/ dist/ downloads/ diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 93f2d004..5f75b15f 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -20,19 +20,19 @@ In the ``root directory`` of this repository you will find a script called ``cre When executing this script, it expects exactly one argument: the new name of the release / tag. Here you need to provide always the syntax ``X.X.X``, e.g. ``0.1.9``, ``0.5.0`` or ``1.0.0``. -The script will do two things automatically for you: -1. Updating the version string in the **[\_\_about\_\_.py](src/Tables/__about__.py)** -2. Creating & Pushing a new tag to GitHub. +The package version is read from the Git tag. No version file needs to be changed or committed. Create and push a tag from the desired commit: -Execute the following command to create a new release: ``` cd -./create_release.sh 1.0.0 +git checkout main +git pull origin main +git tag -a v1.0.0 -m "Release v1.0.0" +git push origin v1.0.0 ``` -After executing the script, three pipeline jobs are getting triggered automatically: +After pushing the tag, three pipeline jobs are triggered automatically: 1. First job creates a new ``Release`` in github with the name of the created ``Tag``. -2. Second job uploads the new wheel package to ``PyPi`` with the ``__version__`` from the ``__about__.py`` file. +2. Second job builds the wheel with the version from the Git tag and uploads it to ``PyPi``. 3. Third job generates a new keyword documentation via ``libdoc`` on the main branch, but pushes it to the ``gh_pages`` where it is available as public ``GitHub Page``. ### *Backup* - Manual Version Bump & Tag Creation @@ -40,29 +40,21 @@ After executing the script, three pipeline jobs are getting triggered automatica If the preferred way using the ``create_release.sh`` script does not work, you can also manually create a new release. Therefore, execute the following steps. -#### 1. Increase Version +#### Create a new tag -Open the file **[\_\_about\_\_.py](src/Tables/__about__.py)** and increase the version (``0.0.5 = major.minor.path``) before building & uploading the new python wheel package! - -The new version **must be unique** & **not already existing** in ``PyPi`` & ``GitHub Releases``!!! - -Commit & push the changed version into the ``main`` branch of the repository. - -#### 2. Create new Tag - -Now, create a new tag from the main branch with the syntax ``vX.X.X`` -> example: ``v1.0.5``. +Create a new tag from the desired commit with the syntax ``vX.X.X``. The version must be unique in PyPI and GitHub Releases. Use the following commands to create & push the tag: ``` -git tag v0.0.5 -git push origin v0.0.5 +git tag -a v1.0.0 -m "Release v1.0.0" +git push origin v1.0.0 ``` -#### 2.1. Creating GitHub Release & Deploy Wheel Package to PyPi +#### Creating GitHub Release & Deploy Wheel Package to PyPi After pushing the new tag, three pipeline jobs are getting triggered automatically: 1. First job creates a new ``Release`` in github with the name of the created ``Tag``. -2. Second job uploads the new wheel package to ``PyPi`` with the ``__version__`` from the ``__about__.py`` file. +2. Second job builds the wheel with the version from the Git tag and uploads it to ``PyPi``. 3. Third job generates a new keyword documentation via ``libdoc`` on the main branch, but pushes it to the ``gh_pages`` where it is available as public ``GitHub Page``. ## Installing Dev Dependencies diff --git a/create_release.sh b/create_release.sh index 12919644..c837b322 100755 --- a/create_release.sh +++ b/create_release.sh @@ -8,25 +8,25 @@ if [ -z "$1" ]; then fi NEW_VERSION="$1" -FILE="src/Tables/__about__.py" +TAG="v${NEW_VERSION}" -echo "🔧 Updating version to '${NEW_VERSION}' in '${FILE}'" - -# Example: __version__ = "0.0.6" → __version__ = "0.0.7" -if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' -E "s/^(__version__ *= *\")[^\"]+/\1${NEW_VERSION}/" src/Tables/__about__.py -else - sed -i.bak -E "s/^(__version__\s*=\s*\")[^\"]+\"/\1${NEW_VERSION}\"/" "$FILE" +if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "❌ Tag '${TAG}' already exists locally." + exit 1 fi -rm -f "${FILE}.bak" +if git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null 2>&1; then + echo "❌ Tag '${TAG}' already exists on origin." + exit 1 +fi -git checkout main -git add "$FILE" -git commit -m "Bump version to ${NEW_VERSION}" -git push origin HEAD +if ! git diff --quiet || ! git diff --cached --quiet; then + echo "❌ Working tree has uncommitted changes. Commit or stash them before creating a release." + exit 1 +fi -git tag -a "v${NEW_VERSION}" -m "Release v${NEW_VERSION}" -git push origin "v${NEW_VERSION}" +echo "🏷️ Creating '${TAG}' on the current commit" +git tag -a "$TAG" -m "Release ${TAG}" +git push origin "$TAG" -echo "✅ Version bumped to '${NEW_VERSION}', committed and tagged. PyPi Release is going to be created... 🚀" +echo "✅ Tag '${TAG}' created and pushed. GitHub Actions will build and publish the release." diff --git a/pyproject.toml b/pyproject.toml index 71384edd..49acda6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" [project] @@ -60,7 +60,10 @@ only-include = ["src/Tables"] sources = ["src"] [tool.hatch.version] -path = "src/Tables/__about__.py" +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "src/Tables/_version.py" [tool.hatch.build] dev-mode-dirs = ["src"] @@ -93,7 +96,7 @@ source_pkgs = ["Tables", "tests"] branch = true parallel = true omit = [ - "src/Tables/__about__.py", + "src/Tables/_version.py", ] [tool.coverage.paths] diff --git a/src/Tables/__about__.py b/src/Tables/__about__.py deleted file mode 100644 index 82c6ba23..00000000 --- a/src/Tables/__about__.py +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-FileCopyrightText: 2025-present Marvin Klerx -# -# SPDX-License-Identifier: MIT -__version__ = "0.3.0" diff --git a/src/Tables/__init__.py b/src/Tables/__init__.py index 96bc45db..462ac95f 100644 --- a/src/Tables/__init__.py +++ b/src/Tables/__init__.py @@ -7,7 +7,7 @@ from Tables.utils.settings_stack import Scope, SettingsStack -from .__about__ import __version__ +from ._version import __version__ from .keywords import ( Configuration, Getter,