diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81e3b49..d0e8df6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,11 +10,11 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.13" - - run: pipx install poetry==2.0.1 + - run: pipx install poetry==2.4.1 - run: poetry sync - run: poetry run pre-commit run --all-files @@ -24,11 +24,11 @@ jobs: matrix: python-version: ["3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: ${{ matrix.python-version }} - - run: pipx install poetry==2.0.1 + - run: pipx install poetry==2.4.1 - run: poetry sync - run: poetry run pytest --cov=altissimo --cov-report=term-missing --cov-fail-under=80 @@ -36,9 +36,9 @@ jobs: needs: [lint, test] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.13" - - run: pipx install poetry==2.0.1 + - run: pipx install poetry==2.4.1 - run: poetry build diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..2b53764 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,72 @@ +name: Build and publish to PyPI + +on: + push: + tags: + - "v*" + # Run by hand to publish the current branch to TestPyPI, to check the package + # before a release + workflow_dispatch: + +jobs: + build: + name: Test and build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: "3.13" + - run: pipx install poetry==2.4.1 + - run: poetry sync --with dev --all-extras + - run: poetry run pytest -q + - name: Check the tag matches the package version + if: startsWith(github.ref, 'refs/tags/') + run: | + version="$(poetry version -s)" + if [ "${GITHUB_REF_NAME}" != "v${version}" ]; then + echo "Tag ${GITHUB_REF_NAME} does not match package version ${version}" >&2 + exit 1 + fi + - run: poetry build + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: package-dist + path: dist + + publish: + name: Publish to PyPI + needs: build + # Only publish tags from this repo. Forks can't publish. + if: github.repository == 'altissimo-hq/mixpanel-python' && startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + environment: pypi + permissions: + # Mandatory for PyPI Trusted Publishing + id-token: write + steps: + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: package-dist + path: dist + - uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 + + publish-test: + name: Publish to TestPyPI + needs: build + if: github.repository == 'altissimo-hq/mixpanel-python' && github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + environment: testpypi + permissions: + # Mandatory for PyPI Trusted Publishing + id-token: write + steps: + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: package-dist + path: dist + - uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 + with: + repository-url: https://test.pypi.org/legacy/ + # A version can only be uploaded once, so reruns skip it + skip-existing: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 6263e0d..b2a8514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.1.0] - Unreleased +## [0.1.0] - 2026-10-26 + +First release, published to PyPI as `altissimo-mixpanel`. The import name is +`altissimo.mixpanel`. Licensed under Apache-2.0. ### Added @@ -28,4 +31,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `MixpanelError` and `MixpanelImportError` exception hierarchy - Lazy SDK import — zero import-time side effects - PEP 561 `py.typed` marker -- CI pipeline with lint, test (Python 3.11–3.13), and build stages +- CI pipeline with lint, test (Python 3.11–3.13), and build stages, using Poetry 2.4.1 with actions pinned by + commit +- A publish workflow: tagged releases (`v*`) are tested, checked against the package version, built, and uploaded + to PyPI through Trusted Publishing (environment `pypi`). Running it by hand uploads the current branch to + TestPyPI (environment `testpypi`). +- Renovate configuration, using the shared `altissimo-hq/renovate-config` preset diff --git a/README.md b/README.md index 0ea6d12..0587eaf 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Reusable, typed Mixpanel analytics client for Altissimo projects. - **Typed API** — full type annotations for all operations - **Lazy SDK import** — `mixpanel` is imported only when needed, zero import-time side effects -- **Disabled mode** — silently no-op all calls when analytics isn't configured +- **Disabled mode** — no-op all calls when analytics is turned off or isn't configured - **Error handling** — swallow-and-log by default, configurable via `on_error` - **Protocol for DI** — `MixpanelClientProtocol` for dependency injection - **Test helpers** — `FakeMixpanelClient` records all calls in-memory @@ -14,9 +14,12 @@ Reusable, typed Mixpanel analytics client for Altissimo projects. ## Installation +Published on PyPI as [`altissimo-mixpanel`](https://pypi.org/project/altissimo-mixpanel/); +the import name is `altissimo.mixpanel`. + ```bash # With the Mixpanel SDK (recommended) -pip install altissimo-mixpanel[mixpanel] +pip install "altissimo-mixpanel[mixpanel]" # Without the SDK (for type checking / protocol-only usage) pip install altissimo-mixpanel @@ -217,4 +220,4 @@ poetry run ruff format . ## License -[GPL-3.0-or-later](LICENSE) +[Apache-2.0](LICENSE) diff --git a/pyproject.toml b/pyproject.toml index 454e343..3229cd1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "altissimo-mixpanel" version = "0.1.0" description = "Reusable Mixpanel analytics client for Altissimo projects" readme = "README.md" -license = "GPL-3.0-or-later" +license = "Apache-2.0" requires-python = ">=3.11" authors = [ { name = "Altissimo HQ" }, @@ -12,7 +12,6 @@ keywords = ["mixpanel", "analytics", "altissimo"] classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", - "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", @@ -32,11 +31,10 @@ Issues = "https://github.com/altissimo-hq/mixpanel-python/issues" Changelog = "https://github.com/altissimo-hq/mixpanel-python/blob/main/CHANGELOG.md" [build-system] -requires = ["poetry-core>=2.0"] +requires = ["poetry-core>=2.2.0,<3.0.0"] build-backend = "poetry.core.masonry.api" [tool.poetry] -name = "altissimo-mixpanel" packages = [ { include = "altissimo", from = "src" }, ] diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..f275cab --- /dev/null +++ b/renovate.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["github>altissimo-hq/renovate-config"] +}