Merge pull request #21 from Nonannet/dev

added automatic git based versioning
This commit is contained in:
Nicolas Kruse 2025-12-31 17:06:00 +01:00 committed by GitHub
commit 0bc637bdac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 35 additions and 17 deletions

View File

@ -41,6 +41,8 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-tags: true
- uses: actions/download-artifact@v4
with:
@ -87,6 +89,8 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-tags: true
- uses: actions/download-artifact@v4
with:
@ -140,6 +144,8 @@ jobs:
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- uses: actions/download-artifact@v4
with:
name: stencil-object-files
@ -169,6 +175,8 @@ jobs:
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- uses: actions/download-artifact@v4
with:
name: stencil-object-files
@ -198,6 +206,8 @@ jobs:
continue-on-error: true
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- uses: actions/download-artifact@v4
with:
name: stencil-object-files
@ -232,6 +242,8 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-tags: true
- uses: actions/download-artifact@v4
with:
@ -279,6 +291,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-tags: true
sparse-checkout: |
pyproject.toml
tools/get_tag.sh
@ -325,6 +338,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- uses: actions/download-artifact@v4
with:

View File

@ -1,6 +1,6 @@
[project]
name = "copapy"
version = "0.0.3"
dynamic = ["version"]
authors = [
{ name="Nicolas Kruse", email="nicolas.kruse@nonan.net" },
]
@ -20,7 +20,7 @@ Homepage = "https://github.com/nonannet/copapy"
Issues = "https://github.com/nonannet/copapy/issues"
[build-system]
requires = ["setuptools>=61.0", "wheel"]
requires = ["setuptools>=61.0", "setuptools-scm>=8", "wheel"]
build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find]
@ -29,6 +29,17 @@ where = ["src"]
[tool.setuptools.package-data]
copapy = ["obj/*.o", "py.typed"]
[tool.setuptools_scm]
version_scheme = "post-release"
local_scheme = "node-and-date"
tag_regex = "^v(?P<version>\\d+\\.\\d+\\.\\d+(?:-beta)?)$"
fallback_version = "0.0.0"
write_to = "src/copapy/_version.py"
write_to_template = '''
# generated by setuptools_scm - do not edit
__version__ = "{version}"
'''
[project.optional-dependencies]
dev = [
"ruff",

View File

@ -40,9 +40,11 @@ from ._tensors import tensor, zeros, ones, arange, eye, identity, diagonal
from ._math import sqrt, abs, sign, sin, cos, tan, asin, acos, atan, atan2, log, exp, pow, get_42, clamp, min, max, relu
from ._autograd import grad
from ._tensors import tensor as matrix
from ._version import __version__
__all__ = [
"__version__",
"Target",
"NumLike",
"value",

2
src/copapy/_version.py Normal file
View File

@ -0,0 +1,2 @@
# generated by setuptools_scm - do not edit
__version__ = "0.0.0"

View File

@ -10,18 +10,6 @@ if [[ "${GITHUB_REF:-}" == refs/tags/* ]]; then
exit 0
fi
# Otherwise, extract version from pyproject.toml
if [[ -f pyproject.toml ]]; then
VERSION=$(grep -E '^version\s*=' pyproject.toml \
| sed -E 's/version\s*=\s*"([^"]+)"/\1/' \
| tr -d '\r\n')
if [[ -z "$VERSION" ]]; then
echo "! Could not find version in pyproject.toml" >&2
exit 1
fi
echo "Detected version from pyproject.toml: v$VERSION-beta"
echo "version=v$VERSION-beta" >> "${GITHUB_OUTPUT:-/dev/stdout}"
else
echo "! pyproject.toml not found" >&2
exit 1
fi
# Detected version from Git
TAG_NAME=$(git describe --tags --abbrev=0)
echo "version=$TAG_NAME" >> "${GITHUB_OUTPUT:-/dev/stdout}"