diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 25b94b6..6388e89 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,3 +8,12 @@ updates: open-pull-requests-limit: 5 labels: - "dependencies" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + open-pull-requests-limit: 5 + labels: + - "dependencies" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..57e35cb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: CI + +on: + push: + branches: ["**"] + pull_request: + branches: ["**"] + +jobs: + lint: + name: Lint & Format + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6.0.2 + + - uses: actions/setup-python@v6.2.0 + with: + python-version: "3.12" + + - uses: astral-sh/setup-uv@v7.5.0 + + - run: uv pip install --system ".[dev]" + + - run: ruff check . + + - run: black --check . --target-version py312 + + test: + name: Tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6.0.2 + + - uses: actions/setup-python@v6.2.0 + with: + python-version: "3.12" + + - uses: astral-sh/setup-uv@v7.5.0 + + - run: uv pip install --system ".[dev]" + + - name: Write cookies.json + if: ${{ env.COOKIES_JSON != '' }} + run: echo "$COOKIES_JSON" > cookies.json + env: + COOKIES_JSON: ${{ secrets.COOKIES_JSON }} + + - run: pytest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index ed1ead3..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Lint - -on: - push: - branches: [master] - pull_request: - branches: [master] - -jobs: - lint: - name: Lint & format - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v6.0.2 - - - uses: actions/setup-python@v6.2.0 - with: - python-version: "3.12" - - - name: Install uv - uses: astral-sh/setup-uv@v7.5.0 - - - name: Install dev dependencies - run: uv pip install --system ".[dev]" - - - name: Run ruff - run: ruff check . - - - name: Run black - run: black --check . --target-version py312 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1d96144..1b575e9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,12 +1,44 @@ -name: Publish to PyPI +name: Publish on: - push: + workflow_run: + workflows: ["CI"] + types: [completed] branches: [master] jobs: + version-check: + name: Version Check + if: github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.value }} + is-new: ${{ steps.tag.outputs.is-new }} + + steps: + - uses: actions/checkout@v6.0.2 + with: + fetch-depth: 0 + + - name: Read version + id: version + run: | + value=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') + echo "value=$value" >> $GITHUB_OUTPUT + + - name: Check tag + id: tag + run: | + if git ls-remote --tags origin "refs/tags/v${{ steps.version.outputs.value }}" | grep -q .; then + echo "is-new=false" >> $GITHUB_OUTPUT + else + echo "is-new=true" >> $GITHUB_OUTPUT + fi + build: name: Build + needs: version-check + if: needs.version-check.outputs.is-new == 'true' runs-on: ubuntu-latest steps: @@ -16,23 +48,19 @@ jobs: with: python-version: "3.12" - - name: Install uv - uses: astral-sh/setup-uv@v7.5.0 + - uses: astral-sh/setup-uv@v7.5.0 - - name: Build distribution - run: uv build + - run: uv build - - name: Upload artifacts - uses: actions/upload-artifact@v7 + - uses: actions/upload-artifact@v7 with: name: dist path: dist/* publish: - name: Publish - needs: build + name: Publish to PyPI + needs: [version-check, build] runs-on: ubuntu-latest - if: github.ref == 'refs/heads/master' environment: name: pypi url: https://pypi.org/project/pyfragment/ @@ -40,11 +68,34 @@ jobs: id-token: write steps: - - name: Download artifacts - uses: actions/download-artifact@v8.0.1 + - uses: actions/download-artifact@v8.0.1 with: name: dist path: dist - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1.13.0 + - uses: pypa/gh-action-pypi-publish@v1.13.0 + + release: + name: GitHub Release + needs: [version-check, build] + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v6.0.2 + with: + fetch-depth: 0 + + - uses: actions/download-artifact@v8.0.1 + with: + name: dist + path: dist + + - uses: softprops/action-gh-release@v2.6.1 + with: + tag_name: v${{ needs.version-check.outputs.version }} + name: v${{ needs.version-check.outputs.version }} + files: dist/* + generate_release_notes: true + make_latest: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 4edd34f..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Tests - -on: - push: - branches: ["**"] - pull_request: - branches: ["**"] - -jobs: - test: - name: Run tests - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v6.0.2 - - - uses: actions/setup-python@v6.2.0 - with: - python-version: "3.12" - - - name: Install uv - uses: astral-sh/setup-uv@v7.5.0 - - - name: Install dependencies - run: uv pip install --system ".[dev]" - - - name: Write cookies.json - if: ${{ env.COOKIES_JSON != '' }} - run: echo "$COOKIES_JSON" > cookies.json - env: - COOKIES_JSON: ${{ secrets.COOKIES_JSON }} - - - name: Run tests - run: pytest diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..48134f1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,23 @@ +# Changelog + +All notable changes to pyfragment are documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project uses [Calendar Versioning](https://calver.org/) (`YYYY.MINOR.MICRO`). + +--- + +## [2026.0.1] — 2026-03-16 + +### Added +- Initial stable release of `pyfragment` +- `FragmentClient` — async client for the Fragment.com API +- `gift_premium(username, months)` — purchase Telegram Premium for any user (3, 6, or 12 months) +- `gift_stars(username, amount)` — send Telegram Stars to any user (50–1,000,000) +- `topup_ton(username, amount)` — top up TON Ads balance (1–1,000,000,000 TON) +- `get_wallet()` — fetch wallet address and balance +- Support for TON wallet versions `V4R2` and `V5R1` +- Structured exception hierarchy (`FragmentError`, `ConfigurationError`, `CookieError`, etc.) +- `py.typed` marker — full PEP 561 typing support for type-checkers + +[2026.0.1]: https://github.com/bohd4nx/pyfragment/releases/tag/v2026.0.1 diff --git a/README.md b/README.md index 6640ce6..5ae7d3d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![Python](https://img.shields.io/badge/Python-3.12+-3776AB?style=flat&logo=python&logoColor=white)](https://python.org) [![License](https://img.shields.io/github/license/bohd4nx/pyfragment?style=flat&color=lightgrey)](LICENSE) [![Stars](https://img.shields.io/github/stars/bohd4nx/pyfragment?style=flat&color=yellow)](https://github.com/bohd4nx/pyfragment/stargazers) -[![CI](https://img.shields.io/github/actions/workflow/status/bohd4nx/pyfragment/tests.yml?style=flat&label=tests&logo=github)](https://github.com/bohd4nx/pyfragment/actions) +[![CI](https://img.shields.io/github/actions/workflow/status/bohd4nx/pyfragment/ci.yml?style=flat&label=tests&logo=github)](https://github.com/bohd4nx/pyfragment/actions) [Report Bug](https://github.com/bohd4nx/pyfragment/issues) · [Request Feature](https://github.com/bohd4nx/pyfragment/issues) · [**Donate TON**](https://app.tonkeeper.com/transfer/UQCppfw5DxWgdVHf3zkmZS8k1mt9oAUYxQLwq2fz3nhO8No5) diff --git a/pyfragment/__init__.py b/pyfragment/__init__.py index 9495146..d08f26e 100644 --- a/pyfragment/__init__.py +++ b/pyfragment/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2025 bohd4nx +# Copyright (c) 2026 bohd4nx # # This source code is licensed under the MIT License found in the # LICENSE file in the root directory of this source tree. diff --git a/pyfragment/py.typed b/pyfragment/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml index dadce56..1f41d60 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "pyfragment" -version = "2026.1.0" +version = "2026.0.1" description = "Python library for the Fragment.com API — purchase Telegram Stars, Premium, and top up TON Ads balance." readme = "README.md" license = { text = "MIT" } @@ -42,6 +42,7 @@ dev = [ Homepage = "https://github.com/bohd4nx/pyfragment" Repository = "https://github.com/bohd4nx/pyfragment" Issues = "https://github.com/bohd4nx/pyfragment/issues" +Changelog = "https://github.com/bohd4nx/pyfragment/blob/master/CHANGELOG.md" [tool.hatch.build.targets.wheel] packages = ["pyfragment"]