Skip to content
Merged
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
3 changes: 3 additions & 0 deletions auto-tagger/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.venv
.mypy_cache
.ruff_cache
42 changes: 21 additions & 21 deletions auto-tagger/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
FROM python:3.13-alpine AS builder
HEALTHCHECK NONE

ENV PATH="${PATH}:/app/.local/bin" \
POETRY_VERSION=2.1.2 \
PYTHONDONTWRITEBYTECODE=1 \
POETRY_CACHE_DIR=/app/.cache \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
UV_PYTHON_DOWNLOADS=never \
UV_PYTHON=python3.13 \
UV_NO_PROGRESS=1

# kics-scan ignore-line
RUN apk add --no-cache musl-dev libffi-dev gcc
RUN addgroup -g 1000 app && adduser -G app -u 999 -s /sbin/nologin -h /app app -D
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN chmod -R a+r .
USER app
RUN pip install poetry==${POETRY_VERSION} --no-cache-dir
RUN poetry install --only main
RUN --mount=type=cache,target=/root/.cache \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync \
--locked \
--no-dev \
--no-install-project --no-editable
COPY pyproject.toml uv.lock ./
COPY *.py ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-editable --no-dev

FROM python:3.13-alpine AS runtime
HEALTHCHECK NONE

ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:${PATH}"
ENV PATH="/app/.venv/bin:${PATH}"

RUN addgroup -g 1000 app && adduser -G app -u 999 -s /sbin/nologin -h /app app -D
WORKDIR /app
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY *.py ./
COPY --from=builder /app /app
RUN chmod -R a+r .
USER app
LABEL org.opencontainers.image.source=https://github.com/notdodo/github-actions/tree/main/auto-tagger
LABEL org.opencontainers.image.description="A GitHub Action to automatically bump and/or create tags upon push to the default branch, using SemVer formatting."

CMD ["python", "/app/main.py"]
USER app
CMD ["python", "-OO", "/app/main.py"]
14 changes: 7 additions & 7 deletions auto-tagger/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ tasks:
install:
desc: Install Python dependencies
cmds:
- poetry install --no-root
- uv sync

format:
desc: Format repository code
cmds:
- poetry run ruff format
- poetry run ruff check --fix
- uv run ruff format
- uv run ruff check --fix

format-check:
desc: Check the code format (without modifying)
cmds:
- poetry run ruff format --check
- uv run ruff format --check

lint:
desc: Run lint checks
cmds:
- poetry run ruff check
- uv run ruff check

type-check:
desc: Run static type checks
cmds:
- poetry run mypy .
- uv run mypy .

check:
desc: Run formatting check, lint, and type checks
Expand All @@ -42,4 +42,4 @@ tasks:
test:
desc: Run all tests
cmds:
- poetry run pytest
- uv run pytest
5 changes: 3 additions & 2 deletions auto-tagger/github_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import copy
import os
from datetime import datetime, timedelta, timezone
from datetime import UTC, datetime, timedelta

from github import Github, InputGitAuthor
from semver import Version, VersionInfo
Expand All @@ -17,6 +17,7 @@ class GitHubHelper:
"""PyGitHub support class"""

def __init__(self, token: str, config: Configuration) -> None:
"""init class"""
self.token = token
self.config = config
self.repo = Github(token).get_repo(self.config.REPOSITORY)
Expand Down Expand Up @@ -148,7 +149,7 @@ def create_git_tag(self, tag: Tag) -> None:
tagger=InputGitAuthor(
name=str(commit.author.name),
email=str(commit.author.email),
date=str(datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")),
date=str(datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%SZ")),
),
)
self.repo.create_git_ref(f"refs/tags/{tag.name}", tag.commit)
Expand Down
4 changes: 2 additions & 2 deletions auto-tagger/github_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from dataclasses import dataclass, field
from datetime import datetime, timezone
from datetime import UTC, datetime


@dataclass
Expand All @@ -19,7 +19,7 @@ class Commit:

def now_utf() -> datetime:
"""Factory for Datetime"""
return datetime.now(timezone.utc)
return datetime.now(UTC)


@dataclass
Expand Down
895 changes: 0 additions & 895 deletions auto-tagger/poetry.lock

This file was deleted.

46 changes: 19 additions & 27 deletions auto-tagger/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
[tool.poetry]
[project]
name = "auto-tagger"
version = "0.1.0"
description = "A GitHub Action to automatically bump and/or create tags upon push to the default branch, using SemVer formatting."
authors = ["notdodo"]
authors = [
{ name = "notdodo", email = "6991986+notdodo@users.noreply.github.com" },
]
requires-python = ">3.12.0"
readme = "README.md"
package-mode = false
dependencies = ["pygithub>=2.7.0", "semver>=3.0.4"]

[dependency-groups]
dev = [
"mypy[faster-cache]>=1.17.1,<2",
"ruff>=0.12.7,<0.13",
"pydantic>=2.11.7,<3",
]

[tool.poetry.dependencies]
python = "^3.11"
pygithub = "^2.7.0"
semver = "^3.0.4"
[tool.uv]
package = false

[tool.poetry.group.dev.dependencies]
mypy = { extras = ["faster-cache"], version = "^1.17.1" }
pydantic = "^2.11.7"
pylint = "^3.3.8"
ruff = "^0.12.10"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.ruff]
output-format = "github"
Expand All @@ -24,17 +30,7 @@ output-format = "github"
fixable = ["ALL"]
unfixable = []
select = ["ALL"]
ignore = [
"D2",
"D4",
"ANN",
"COM812",
"D107",
"ISC001",
"ERA001",
"N803",
"T201",
]
ignore = ["D2", "D4", "ANN", "COM812", "ISC001", "ERA001", "PLR0913", "T201"]

[tool.ruff.format]
docstring-code-format = true
Expand All @@ -60,7 +56,3 @@ namespace_packages = true
[tool.pylint."MESSAGES CONTROL"]
persistent = "no"
disable = ["fixme", "line-too-long"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Loading
Loading