Skip to content

Commit b04254f

Browse files
authored
changed release creation process (#57)
1 parent b330332 commit b04254f

7 files changed

Lines changed: 41 additions & 45 deletions

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
steps:
1515
- name: Checkout code
1616
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
1719

1820
- name: Create GitHub Release
1921
uses: softprops/action-gh-release@v2
@@ -31,6 +33,8 @@ jobs:
3133
steps:
3234
- name: Checkout code
3335
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 0
3438

3539
- name: Set up Python
3640
uses: actions/setup-python@v5

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __pycache__/
99
# Distribution / packaging
1010
.Python
1111
build/
12+
src/Tables/_version.py
1213
develop-eggs/
1314
dist/
1415
downloads/

DEVELOPMENT.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,49 +20,41 @@ In the ``root directory`` of this repository you will find a script called ``cre
2020
When executing this script, it expects exactly one argument: the new name of the release / tag.
2121
Here you need to provide always the syntax ``X.X.X``, e.g. ``0.1.9``, ``0.5.0`` or ``1.0.0``.
2222

23-
The script will do two things automatically for you:
24-
1. Updating the version string in the **[\_\_about\_\_.py](src/Tables/__about__.py)**
25-
2. Creating & Pushing a new tag to GitHub.
23+
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:
2624

27-
Execute the following command to create a new release:
2825
```
2926
cd <project-root-directory>
30-
./create_release.sh 1.0.0
27+
git checkout main
28+
git pull origin main
29+
git tag -a v1.0.0 -m "Release v1.0.0"
30+
git push origin v1.0.0
3131
```
3232

33-
After executing the script, three pipeline jobs are getting triggered automatically:
33+
After pushing the tag, three pipeline jobs are triggered automatically:
3434
1. First job creates a new ``Release`` in github with the name of the created ``Tag``.
35-
2. Second job uploads the new wheel package to ``PyPi`` with the ``__version__`` from the ``__about__.py`` file.
35+
2. Second job builds the wheel with the version from the Git tag and uploads it to ``PyPi``.
3636
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``.
3737

3838
### *Backup* - Manual Version Bump & Tag Creation
3939

4040
If the preferred way using the ``create_release.sh`` script does not work, you can also manually create a new release.
4141
Therefore, execute the following steps.
4242

43-
#### 1. Increase Version
43+
#### Create a new tag
4444

45-
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!
46-
47-
The new version **must be unique** & **not already existing** in ``PyPi`` & ``GitHub Releases``!!!
48-
49-
Commit & push the changed version into the ``main`` branch of the repository.
50-
51-
#### 2. Create new Tag
52-
53-
Now, create a new tag from the main branch with the syntax ``vX.X.X`` -> example: ``v1.0.5``.
45+
Create a new tag from the desired commit with the syntax ``vX.X.X``. The version must be unique in PyPI and GitHub Releases.
5446

5547
Use the following commands to create & push the tag:
5648
```
57-
git tag v0.0.5
58-
git push origin v0.0.5
49+
git tag -a v1.0.0 -m "Release v1.0.0"
50+
git push origin v1.0.0
5951
```
6052

61-
#### 2.1. Creating GitHub Release & Deploy Wheel Package to PyPi
53+
#### Creating GitHub Release & Deploy Wheel Package to PyPi
6254

6355
After pushing the new tag, three pipeline jobs are getting triggered automatically:
6456
1. First job creates a new ``Release`` in github with the name of the created ``Tag``.
65-
2. Second job uploads the new wheel package to ``PyPi`` with the ``__version__`` from the ``__about__.py`` file.
57+
2. Second job builds the wheel with the version from the Git tag and uploads it to ``PyPi``.
6658
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``.
6759

6860
## Installing Dev Dependencies

create_release.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@ if [ -z "$1" ]; then
88
fi
99

1010
NEW_VERSION="$1"
11-
FILE="src/Tables/__about__.py"
11+
TAG="v${NEW_VERSION}"
1212

13-
echo "🔧 Updating version to '${NEW_VERSION}' in '${FILE}'"
14-
15-
# Example: __version__ = "0.0.6" → __version__ = "0.0.7"
16-
if [[ "$OSTYPE" == "darwin"* ]]; then
17-
sed -i '' -E "s/^(__version__ *= *\")[^\"]+/\1${NEW_VERSION}/" src/Tables/__about__.py
18-
else
19-
sed -i.bak -E "s/^(__version__\s*=\s*\")[^\"]+\"/\1${NEW_VERSION}\"/" "$FILE"
13+
if git rev-parse "$TAG" >/dev/null 2>&1; then
14+
echo "❌ Tag '${TAG}' already exists locally."
15+
exit 1
2016
fi
2117

22-
rm -f "${FILE}.bak"
18+
if git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null 2>&1; then
19+
echo "❌ Tag '${TAG}' already exists on origin."
20+
exit 1
21+
fi
2322

24-
git checkout main
25-
git add "$FILE"
26-
git commit -m "Bump version to ${NEW_VERSION}"
27-
git push origin HEAD
23+
if ! git diff --quiet || ! git diff --cached --quiet; then
24+
echo "❌ Working tree has uncommitted changes. Commit or stash them before creating a release."
25+
exit 1
26+
fi
2827

29-
git tag -a "v${NEW_VERSION}" -m "Release v${NEW_VERSION}"
30-
git push origin "v${NEW_VERSION}"
28+
echo "🏷️ Creating '${TAG}' on the current commit"
29+
git tag -a "$TAG" -m "Release ${TAG}"
30+
git push origin "$TAG"
3131

32-
echo "Version bumped to '${NEW_VERSION}', committed and tagged. PyPi Release is going to be created... 🚀"
32+
echo "Tag '${TAG}' created and pushed. GitHub Actions will build and publish the release."

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["hatchling"]
2+
requires = ["hatchling", "hatch-vcs"]
33
build-backend = "hatchling.build"
44

55
[project]
@@ -60,7 +60,10 @@ only-include = ["src/Tables"]
6060
sources = ["src"]
6161

6262
[tool.hatch.version]
63-
path = "src/Tables/__about__.py"
63+
source = "vcs"
64+
65+
[tool.hatch.build.hooks.vcs]
66+
version-file = "src/Tables/_version.py"
6467

6568
[tool.hatch.build]
6669
dev-mode-dirs = ["src"]
@@ -93,7 +96,7 @@ source_pkgs = ["Tables", "tests"]
9396
branch = true
9497
parallel = true
9598
omit = [
96-
"src/Tables/__about__.py",
99+
"src/Tables/_version.py",
97100
]
98101

99102
[tool.coverage.paths]

src/Tables/__about__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/Tables/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from Tables.utils.settings_stack import Scope, SettingsStack
99

10-
from .__about__ import __version__
10+
from ._version import __version__
1111
from .keywords import (
1212
Configuration,
1313
Getter,

0 commit comments

Comments
 (0)