Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(python): upgrade semver to prevent warnings #2136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
jobs:
release:
permissions:
id-token: write
contents: write # for release publishing

name: Release
Expand Down Expand Up @@ -51,14 +52,15 @@ jobs:
flake8 ./python --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 ./python --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Release Python
- name: Python Semantic Release
if: ${{ contains(env.commitmsg, '(python)') }}
run: |
cd python
pip install packaging
git config --global user.email "[email protected]"
git config --global user.name "manast"
export VERSION=$(semantic-release print-version)
if [ ! -z "$VERSION" ]; then
GH_TOKEN=${{ secrets.GITHUB_TOKEN }} PYPI_TOKEN=${{ secrets.PYPI_TOKEN }} semantic-release publish
fi
uses: python-semantic-release/python-semantic-release@master
with:
directory: ./python
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish package distributions to PyPI
id: pypi-publish
if: ${{ contains(env.commitmsg, '(python)') }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
34 changes: 28 additions & 6 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ keywords = ["python", "bullmq", "queues"]
dependencies = [
"redis >= 4.5.0, < 5",
"msgpack >= 1.0.0, < 2",
"semver >= 2.13.0, < 3"
"semver >= 3.0.1"
]

[project.optional-dependencies]
dev = [
"setuptools==68.0.0",
"pre-commit==3.3.3",
"build==0.8.0",
"python-semantic-release==7.28.1",
"types-redis==4.6.0.2"
]

Expand All @@ -45,11 +44,34 @@ exclude = ["tests*"]
bullmq = ["commands/*.lua", "types/*"]

[tool.semantic_release]
branch = "master"
version_variable = "bullmq/__init__.py:__version__"
version_toml = "pyproject.toml:project.version"
version_variables = ["bullmq/__init__.py:__version__"]
version_toml = ["pyproject.toml:project.version"]
build_command = "python3 setup.py sdist"
tag_format = "vpy{version}"
version_source = "commit"
changelog_file = "../docs/gitbook/python/changelog.md"
upload_to_pypi = true

[tool.semantic_release.commit_parser_options]
allowed_tags = [
"feat",
"fix",
"perf",
]
minor_tags = ["feat"]
patch_tags = ["fix", "perf"]

[tool.semantic_release.changelog]
changelog_file = "../docs/gitbook/python/changelog.md"
exclude_commit_patterns = ["^((?!python).)*$"]
template_dir = "./templates"

[tool.semantic_release.branches.master]
match = "master"
prerelease = false
prerelease_token = "rc"

[tool.semantic_release.remote]
name = "origin"
type = "github"
ignore_token_for_push = false
token = { env = "GH_TOKEN" }
3 changes: 1 addition & 2 deletions python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ msgpack==1.0.5
pipenv==2023.7.4
platformdirs==3.6.0
pre-commit==3.3.3
python-semantic-release==7.28.1
redis==4.6.0
semver==2.13.0
semver==3.0.1
six==1.16.0
virtualenv==20.23.1
virtualenv-clone==0.5.7
22 changes: 22 additions & 0 deletions python/templates/CHANGELOG.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# CHANGELOG
<!--next-version-placeholder-->
{% if context.history.unreleased | length > 0 %}
{# UNRELEASED #}
## Unreleased
{% for type_, commits in context.history.unreleased | dictsort %}
### {{ type_ | capitalize }}
{% for commit in commits %}{% if type_ != "unknown" %}
* {{ commit.message.rstrip() }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% else %}
* {{ commit.message.rstrip() }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% endif %}{% endfor %}{% endfor %}{% endif %}
{% for version, release in context.history.released.items() %}
{# RELEASED #}
## {{ version.as_semver_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }})
{% for type_, commits in release["elements"] | dictsort %}
### {{ type_ | capitalize }}
{% for commit in commits %}{% if type_ != "unknown" %}
* {{ commit.message.rstrip() }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% else %}
* {{ commit.message.rstrip() }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% endif %}{% endfor %}{% endfor %}{% endfor %}