Skip to content

Commit

Permalink
Modify to use setuptools_scm to generate a unique version number for …
Browse files Browse the repository at this point in the history
…each upload
  • Loading branch information
thombashi committed Apr 15, 2024
1 parent 5d7de35 commit ba0c3af
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,24 @@ jobs:
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref_name }}-build
cancel-in-progress: true
timeout-minutes: 20
container:
image: ghcr.io/thombashi/python-ci:3.11

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip
cache-dependency-path: |
setup.py
**/*requirements.txt
tox.ini
- run: make setup-ci

- run: make build

Expand Down Expand Up @@ -56,7 +69,6 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true

- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v2.1.1
Expand Down
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=61.0"]
requires = [
"setuptools>=64",
"setuptools_scm>=7,<8; python_version<'3.8'",
"setuptools_scm>=8; python_version>='3.8'",
]

[tool.setuptools_scm]
version_scheme = "guess-next-dev"
local_scheme = "no-local-version"

[tool.black]
exclude = '''
Expand Down
20 changes: 19 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Dict, Type

import setuptools
from setuptools_scm import ScmVersion


MODULE_NAME = "pathvalidate"
Expand All @@ -16,6 +17,24 @@
pkg_info: Dict[str, str] = {}


def version_scheme(version: ScmVersion) -> str:
from packaging.version import parse
from setuptools_scm import get_version
from setuptools_scm.version import guess_next_version

scm_version = get_version()
parsed_version = parse(scm_version)

if parsed_version.is_devrelease:
return version.format_next_version(guess_next_version, "{guessed}.dev{distance}")

return version.format_with("{tag}")


def no_local_version(version: ScmVersion) -> str:
return ""


def get_release_command_class() -> Dict[str, Type[setuptools.Command]]:
try:
from releasecmd import ReleaseCommand
Expand All @@ -42,7 +61,6 @@ def get_release_command_class() -> Dict[str, Type[setuptools.Command]]:

setuptools.setup(
name=MODULE_NAME,
version=pkg_info["__version__"],
url=REPOSITORY_URL,
author=pkg_info["__author__"],
author_email=pkg_info["__email__"],
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ commands =

[testenv:build]
deps =
build>=0.10
build>=1
twine
wheel
commands =
Expand Down

0 comments on commit ba0c3af

Please sign in to comment.