diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..840876d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,128 @@ +name: "build" + +on: push + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install hatch + run: | + python -m pip install hatch + + - name: Lint (ruff check) + run: hatch run lint + + - name: Type check (pyright) + run: hatch run check + + - name: Tests + run: hatch run test + + build: + name: Build package + runs-on: ubuntu-latest + needs: [test] + steps: + - name: Build + run: hatch build + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: Release + runs-on: ubuntu-latest + if: "startsWith(github.ref, 'refs/tags/')" + needs: [build] + environment: + name: pypi + url: https://pypi.org/p/yapcache + permissions: + id-token: write + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: >- + Sign the Python 🐍 distribution 📦 with Sigstore + and upload them to GitHub Release + needs: + - publish-to-pypi + runs-on: ubuntu-latest + + permissions: + contents: write + id-token: write + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v2.1.1 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' + + publish-to-testpypi: + name: Publish Python 🐍 distribution 📦 to TestPyPI + needs: [build] + runs-on: ubuntu-latest + + environment: + name: testpypi + url: https://test.pypi.org/p/yapcache + + permissions: + id-token: write + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ diff --git a/pyproject.toml b/pyproject.toml index 35ea425..0c12459 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ keywords = [] authors = [{ name = "Erle Carrara", email = "carrara.erle@gmail.com" }] classifiers = [ "Programming Language :: Python", + "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", @@ -30,21 +31,18 @@ Source = "https://github.com/ecarrara/yapcache" path = "src/yapcache/__about__.py" [tool.hatch.envs.default] -dependencies = ["coverage[toml]>=6.5", "pytest", "ruff"] +dependencies = ["coverage[toml]>=6.5", "pytest", "ruff", "pyright"] [tool.hatch.envs.default.scripts] test = "pytest {args:tests}" test-cov = "coverage run -m pytest {args:tests}" cov-report = ["- coverage combine", "coverage report"] cov = ["test-cov", "cov-report"] +lint = "ruff check {args:src/yapcache tests}" +check = "pyright {args:src/yapcache tests}" [[tool.hatch.envs.all.matrix]] -python = ["3.8", "3.9", "3.10", "3.11", "3.12"] - -[tool.hatch.envs.types] -dependencies = ["mypy>=1.0.0"] -[tool.hatch.envs.types.scripts] -check = "mypy --install-types --non-interactive {args:src/yapcache tests}" +python = ["3.10", "3.11", "3.12"] [tool.coverage.run] source_pkgs = ["yapcache", "tests"]