Skip to content

Commit

Permalink
Merge pull request #33 from DataChefHQ/29-add-automatic-versioning-to…
Browse files Browse the repository at this point in the history
…-python

feat(python): add automatic versioning using release script.
  • Loading branch information
shahinism authored Jul 22, 2024
2 parents 1c31faf + aa6c11e commit 7897c13
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
19 changes: 19 additions & 0 deletions includes/README.release.md.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Release

To release a new version, you can use automatic `release` command
installed by `devenv` scripts. This script will:

1. Bump the version based on [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) format found
in the commit history.
2. Update `CHANGELOG.MD`.
3. Assign version tag to the repository.

After the script finished successfully, you need to:

1. Commit changes.
2. `git push` and `git push --tags`.

If you want to have a release on your source control system, Github or
Gitlab, you can do it dependent to the system, using the published
tags.
2 changes: 2 additions & 0 deletions includes/base.nix.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# https://devenv.sh/scripts/
scripts.hello.exec = "echo $GREET";

{% block script %}{% endblock %}

enterShell = ''
hello
'';
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# {{project_name}}

{% include pathjoin("includes", "README.release.md.jinja") %}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ epc
};
{% endblock %}

{% block script %}
# This script is temporary due to two problems:
# 1. `cz` requires a personal github token to publish a release https://commitizen-tools.github.io/commitizen/tutorials/github_actions/
# 2. `cz bump` fails to sign in a terminal: https://github.com/commitizen-tools/commitizen/issues/1184
scripts.release = {
exec = ''
rm CHANGELOG.md
cz bump --files-only --check-consistency
git tag $(python -c "from src.{{ project_name }} import __version__; print(__version__)")
'';
description = ''
Release a new version and update the CHANGELOG.
'';
};
{% endblock %}

{% block hooks %}
ruff.enable = true;
pyright.enable = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ build-backend = "pdm.backend"
[tool.pdm]
distribution = true

[tool.pdm.version]
source = "scm"
path = "src/{{project_name}}/__init__.py"

[tool.pdm.dev-dependencies]
dev = [
"Commitizen>=3.28.0",
"pdbpp>=0.10.3",
]
[tool.commitizen]
version = "1.0.0"
update_changelog_on_bump = true
version_provider = "scm"
tag_format = "v$major.$minor.$patch$prerelease"
version_files = [
"src/{{project_name}}/__init__.py"
]

[tool.ruff]
line-length = 120
target-version = "py311"
Expand Down

0 comments on commit 7897c13

Please sign in to comment.