Use dynamic versioning
Some checks failed
/ build (push) Failing after 8s

This commit is contained in:
phil 2025-03-16 18:25:44 +01:00
parent c06e45029d
commit 746221d13d
4 changed files with 88 additions and 28 deletions

View file

@ -9,7 +9,7 @@ on:
type: boolean type: boolean
jobs: jobs:
test: build:
runs-on: container runs-on: container
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -19,29 +19,31 @@ jobs:
- name: Install the latest version of uv - name: Install the latest version of uv
uses: astral-sh/setup-uv@v4 uses: astral-sh/setup-uv@v4
with: with:
version: "0.5.10" version: "0.6.6"
- name: Install - name: Install
run: uv sync run: uv sync
- name: Build wheel
run: uv build --wheel
- name: Publish Python package (home)
env:
LOCAL_PYPI_TOKEN: ${{ secrets.LOCAL_PYPI_TOKEN }}
run: uv publish --publish-url https://code.philo.ydns.eu/api/packages/philorg/pypi --token $LOCAL_PYPI_TOKEN
- name: Get version - name: Get version
id: version run: echo "VERSION=$(.venv/bin/dunamai from any --style semver)" >> $GITHUB_ENV
run: echo "version=$(.venv/bin/tinyseady-mailer --version)" >> $GITHUB_OUTPUT
- name: Version
run: echo $VERSION
- name: Get distance from tag
run: echo "DISTANCE=$(.venv/bin/dunamai from any --format '{distance}')" >> $GITHUB_ENV
- name: Distance
run: echo $DISTANCE
- name: Workaround for bug of podman-login - name: Workaround for bug of podman-login
if: env.DISTANCE == '0'
run: | run: |
mkdir -p $HOME/.docker mkdir -p $HOME/.docker
echo "{ \"auths\": {} }" > $HOME/.docker/config.json echo "{ \"auths\": {} }" > $HOME/.docker/config.json
- name: Log in to the container registry (with another workaround) - name: Log in to the container registry (with another workaround)
if: env.DISTANCE == '0'
uses: actions/podman-login@v1 uses: actions/podman-login@v1
with: with:
registry: ${{ vars.REGISTRY }} registry: ${{ vars.REGISTRY }}
@ -50,18 +52,31 @@ jobs:
auth_file_path: /tmp/auth.json auth_file_path: /tmp/auth.json
- name: Build the container image - name: Build the container image
if: env.DISTANCE == '0'
uses: actions/buildah-build@v1 uses: actions/buildah-build@v1
with: with:
image: tinyseady-mailer image: tinysteady-mailer
oci: true oci: true
labels: tinyseady-mailer labels: tinysteady-mailer
tags: latest ${{ steps.version.outputs.version }} tags: "latest ${{ env.VERSION }}"
containerfiles: | containerfiles: |
./Containerfile ./Containerfile
- name: Push the image to the registry - name: Push the image to the registry
if: env.DISTANCE == '0'
uses: actions/push-to-registry@v2 uses: actions/push-to-registry@v2
with: with:
registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}" registry: "docker://${{ vars.REGISTRY }}/${{ vars.ORGANISATION }}"
image: tinyseady-mailer image: tinysteady-mailer
tags: latest ${{ steps.version.outputs.version }} tags: "latest ${{ env.VERSION }}"
- name: Build wheel
if: env.DISTANCE == '0'
run: uv build --wheel
- name: Publish Python package (home)
if: env.DISTANCE == '0'
env:
LOCAL_PYPI_TOKEN: ${{ secrets.LOCAL_PYPI_TOKEN }}
run: uv publish --publish-url https://code.philo.ydns.eu/api/packages/philorg/pypi --token $LOCAL_PYPI_TOKEN
continue-on-error: true

View file

@ -1,7 +1,7 @@
[project] [project]
name = "tinysteady-mailer" name = "tinysteady-mailer"
version = "0.1.2"
description = "A tiny and resolute mailer CLI app" description = "A tiny and resolute mailer CLI app"
dynamic = ["version"]
readme = "README.md" readme = "README.md"
license = { text = "MIT License" } license = { text = "MIT License" }
authors = [{ name = "phil", email = "phil.dev@philome.mooo.com" }] authors = [{ name = "phil", email = "phil.dev@philome.mooo.com" }]
@ -29,4 +29,24 @@ Issues = "https://code.philo.ydns.eu/philorg/tinysteady-mailer/issues"
tinysteady-mailer = "tinysteady_mailer:main" tinysteady-mailer = "tinysteady_mailer:main"
[dependency-groups] [dependency-groups]
dev = ["ipdb>=0.13.13", "ipython>=8.30.0"] dev = ["dunamai>=1.23.0", "ipdb>=0.13.13", "ipython>=8.30.0"]
[build-system]
requires = ["hatchling", "uv-dynamic-versioning"]
build-backend = "hatchling.build"
[tool.hatch.version]
source = "uv-dynamic-versioning"
[tool.hatch.build.targets.wheel]
packages = ["src/tinysteady_mailer"]
package = true
[tool.uv-dynamic-versioning]
style = "semver"
[tool.uv]
package = true
[tool.black]
line-length = 98

View file

@ -1,8 +1,14 @@
import sys import sys
import asyncio import asyncio
from .tsmailer import mailer, CONFIG from tinysteady_mailer.tsmailer import mailer, CONFIG
try:
from dunamai import Version, Style
__version__ = Version.from_git().serialize(style=Style.SemVer, dirty=True)
except ImportError:
__version__ = importlib.metadata.version("treetrail-backend")
__doc__ = ( __doc__ = (
"Send mails in batches. " "Send mails in batches. "
@ -15,14 +21,10 @@ def main() -> None:
from argparse import ArgumentParser from argparse import ArgumentParser
parser = ArgumentParser(description=__doc__) parser = ArgumentParser(description=__doc__)
parser.add_argument( parser.add_argument("-v", "--version", action="store_true", help="Print version and exit")
"-v", "--version", action="store_true", help="Print version and exit"
)
args = parser.parse_args() args = parser.parse_args()
if args.version: if args.version:
from importlib.metadata import version print(__version__)
print(version("tinysteady-mailer"))
sys.exit(0) sys.exit(0)
if CONFIG is None: if CONFIG is None:

27
uv.lock generated
View file

@ -1,4 +1,5 @@
version = 1 version = 1
revision = 1
requires-python = ">=3.12" requires-python = ">=3.12"
[[package]] [[package]]
@ -68,6 +69,18 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/68/1b/e0a87d256e40e8c888847551b20a017a6b98139178505dc7ffb96f04e954/dnspython-2.7.0-py3-none-any.whl", hash = "sha256:b4c34b7d10b51bcc3a5071e7b8dee77939f1e878477eeecc965e9835f63c6c86", size = 313632 }, { url = "https://files.pythonhosted.org/packages/68/1b/e0a87d256e40e8c888847551b20a017a6b98139178505dc7ffb96f04e954/dnspython-2.7.0-py3-none-any.whl", hash = "sha256:b4c34b7d10b51bcc3a5071e7b8dee77939f1e878477eeecc965e9835f63c6c86", size = 313632 },
] ]
[[package]]
name = "dunamai"
version = "1.23.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "packaging" },
]
sdist = { url = "https://files.pythonhosted.org/packages/06/4e/a5c8c337a1d9ac0384298ade02d322741fb5998041a5ea74d1cd2a4a1d47/dunamai-1.23.0.tar.gz", hash = "sha256:a163746de7ea5acb6dacdab3a6ad621ebc612ed1e528aaa8beedb8887fccd2c4", size = 44681 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/21/4c/963169386309fec4f96fd61210ac0a0666887d0fb0a50205395674d20b71/dunamai-1.23.0-py3-none-any.whl", hash = "sha256:a0906d876e92441793c6a423e16a4802752e723e9c9a5aabdc5535df02dbe041", size = 26342 },
]
[[package]] [[package]]
name = "email-validator" name = "email-validator"
version = "2.2.0" version = "2.2.0"
@ -156,6 +169,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/8f/8e/9ad090d3553c280a8060fbf6e24dc1c0c29704ee7d1c372f0c174aa59285/matplotlib_inline-0.1.7-py3-none-any.whl", hash = "sha256:df192d39a4ff8f21b1895d72e6a13f5fcc5099f00fa84384e0ea28c2cc0653ca", size = 9899 }, { url = "https://files.pythonhosted.org/packages/8f/8e/9ad090d3553c280a8060fbf6e24dc1c0c29704ee7d1c372f0c174aa59285/matplotlib_inline-0.1.7-py3-none-any.whl", hash = "sha256:df192d39a4ff8f21b1895d72e6a13f5fcc5099f00fa84384e0ea28c2cc0653ca", size = 9899 },
] ]
[[package]]
name = "packaging"
version = "24.2"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/d0/63/68dbb6eb2de9cb10ee4c9c14a0148804425e13c4fb20d61cce69f53106da/packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f", size = 163950 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/88/ef/eb23f262cca3c0c4eb7ab1933c3b1f03d021f2c48f54763065b6f0e321be/packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759", size = 65451 },
]
[[package]] [[package]]
name = "parso" name = "parso"
version = "0.8.4" version = "0.8.4"
@ -373,8 +395,7 @@ wheels = [
[[package]] [[package]]
name = "tinysteady-mailer" name = "tinysteady-mailer"
version = "0.1.2" source = { editable = "." }
source = { virtual = "." }
dependencies = [ dependencies = [
{ name = "aiosmtplib" }, { name = "aiosmtplib" },
{ name = "dateutils" }, { name = "dateutils" },
@ -384,6 +405,7 @@ dependencies = [
[package.dev-dependencies] [package.dev-dependencies]
dev = [ dev = [
{ name = "dunamai" },
{ name = "ipdb" }, { name = "ipdb" },
{ name = "ipython" }, { name = "ipython" },
] ]
@ -398,6 +420,7 @@ requires-dist = [
[package.metadata.requires-dev] [package.metadata.requires-dev]
dev = [ dev = [
{ name = "dunamai", specifier = ">=1.23.0" },
{ name = "ipdb", specifier = ">=0.13.13" }, { name = "ipdb", specifier = ">=0.13.13" },
{ name = "ipython", specifier = ">=8.30.0" }, { name = "ipython", specifier = ">=8.30.0" },
] ]