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
51 changes: 21 additions & 30 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@
name: Lint project
name: Lint Project

on:
push:
branches-ignore:
- main

jobs:
lint:
env:
RUNNER_TOOL_CACHE: /opt/hostedtoolcache
PIP_CACHE_DIR: /tmp/pip_cache

runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-22.04

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13.1"
architecture: x64
cache: 'pip'
env:
AGENT_TOOLSDIRECTORY: /opt/hostedtoolcache
PIP_CACHE_DIR: /tmp/pip_cache
uses: actions/checkout@v6

- name: Cache pre-commit hooks
id: cache-pre-commit
uses: actions/cache@v4
- id: setup-uv
uses: astral-sh/setup-uv@v6
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-cache
restore-keys: |
${{ runner.os }}-pre-commit-cache
python-version: 3.14
enable-cache: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
poetry run pre-commit install
uv sync --all-extras --frozen
uv run pre-commit install

- name: Lint pre-commit
run: poetry run pre-commit run --all-files --hook-stage manual
run: uv run pre-commit run --all-files

- name: Run Telegram Notify Action
uses: proDreams/actions-telegram-notifier@main
if: always()
with:
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
chat_id: ${{ secrets.TELEGRAM_CHAT_ID }}
status: ${{ job.status }}
notify_fields: "actor,repository,branch,commit"
message: "Job: pre-commit linters"
79 changes: 79 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Publish to PyPI and GitHub Release

on:
push:
branches:
- main
paths:
- "pyproject.toml"
- "src/**"

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.14"
enable-cache: true

- name: Check if version exists on PyPI
id: check_pypi
run: |
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
NAME=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'])")

echo "Detected version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV

HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://pypi.org/pypi/$NAME/$VERSION/json)

if [ "$HTTP_STATUS" -eq 200 ]; then
echo "::notice::Version $VERSION already exists on PyPI. Skipping publish."
echo "SKIP_PUBLISH=true" >> $GITHUB_ENV
else
echo "Version $VERSION not found on PyPI. Proceeding with publish."
echo "SKIP_PUBLISH=false" >> $GITHUB_ENV
fi

- name: Build package
if: env.SKIP_PUBLISH == 'false'
run: uv build

- name: Publish to PyPI
if: env.SKIP_PUBLISH == 'false'
run: uv publish

- name: Create GitHub Release
if: env.SKIP_PUBLISH == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: v${{ env.VERSION }}
files: dist/*
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run Telegram Notify Action
uses: proDreams/actions-telegram-notifier@main
if: always() && env.SKIP_PUBLISH == 'false'
with:
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
chat_id: ${{ secrets.TELEGRAM_CHAT_ID }}
status: ${{ job.status }}
message: |
<b>New Release: v${{ env.VERSION }}</b>
Repository: ${{ github.repository }}
Actor: ${{ github.actor }}
Status: ${{ job.status }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.venv
__pycache__
.idea
dist
async_yookassa.egg-info/
40 changes: 10 additions & 30 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
exclude: README.md
- id: check-yaml
exclude: ^strings/
- id: check-case-conflict
- id: check-merge-conflict
- id: end-of-file-fixer

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
exclude: __init__.py
args: [ --profile, black, --filter-files ]

- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
rev: v3.21.2
hooks:
- id: pyupgrade
args: [ --py313-plus ]

- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
hooks:
- id: autopep8
args: [ --max-line-length=120, --in-place ]

- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
exclude: "__init__.py"
# args: [ "--ignore=E501,F821,W503", "--max-line-length=120" ]
args: [ "--max-line-length=120" ]
args: [ --py310-plus ]

- repo: https://github.com/psf/black
rev: 24.10.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.11
hooks:
- id: black
language_version: python3.13
args: [ --line-length=120 ]
- id: ruff-check
args: [ "--fix", "--line-length=120" ]
- id: ruff-format
args: [ "--line-length=120" ]
Loading