From 389092ba5f92abb221d2ff65e8e7d4c8231d819b Mon Sep 17 00:00:00 2001 From: Rogger Valverde Date: Sun, 13 Aug 2023 17:06:29 -0500 Subject: [PATCH 1/2] Revert "chore(python): revert #2074 downgrading semver to version 2.13.0 (#2088)" This reverts commit 00271453cb1d5ae347ca56dee73b46c3469608f8. --- .github/workflows/release.yml | 22 ++++++++++++---------- python/pyproject.toml | 33 +++++++++++++++++++++++++++------ python/requirements.txt | 3 +-- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e40dd5f267..b9c6850fd8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,7 @@ env: jobs: release: permissions: + id-token: write contents: write # for release publishing name: Release @@ -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 "manast@taskforce.sh" - 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 }} diff --git a/python/pyproject.toml b/python/pyproject.toml index af598a146b..44f7df10f5 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -22,7 +22,7 @@ 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] @@ -30,7 +30,6 @@ 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" ] @@ -45,11 +44,33 @@ 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).)*$"] + +[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" } diff --git a/python/requirements.txt b/python/requirements.txt index aa6a5ee421..0e34126c28 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -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 From e3eccfa915930a17fc22cea34729a70df39144b6 Mon Sep 17 00:00:00 2001 From: roggervalf Date: Sun, 13 Aug 2023 17:20:52 -0500 Subject: [PATCH 2/2] chore: add changelog template --- python/pyproject.toml | 1 + python/templates/CHANGELOG.md.j2 | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 python/templates/CHANGELOG.md.j2 diff --git a/python/pyproject.toml b/python/pyproject.toml index 44f7df10f5..765d93fce5 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -63,6 +63,7 @@ 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" diff --git a/python/templates/CHANGELOG.md.j2 b/python/templates/CHANGELOG.md.j2 new file mode 100644 index 0000000000..bfbb2621a3 --- /dev/null +++ b/python/templates/CHANGELOG.md.j2 @@ -0,0 +1,22 @@ +# CHANGELOG + +{% 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 %}