Skip to content

Commit

Permalink
Bump dependencies, update docs and workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
nekitdev committed Jun 16, 2024
1 parent 668e810 commit d269b4b
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 57 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ on:

jobs:
check:
name: Check
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,26 @@ on:
branches:
- main

env:
bot-name: nekit[bot]
bot-email: [email protected]
python-version: "3.12"

jobs:
docs:
name: Docs
runs-on: ubuntu-latest

permissions:
contents: write

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

- name: Setup Python 3.12
- name: Setup Python ${{ env.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: ${{ env.python-version }}

- name: Install Poetry
run: pipx install poetry
Expand All @@ -30,8 +38,10 @@ jobs:
- name: Install dependencies
run: poetry install --with docs

- name: Pull
run: git pull
- name: Setup bot user
run: |
git config --local user.name ${{ env.bot-name }}
git config --local user.email ${{ env.bot-email }}
- name: Deploy the documentation
run: poetry run mkdocs gh-deploy
run: poetry run mkdocs gh-deploy --force
133 changes: 123 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,105 @@
name: release

on:
push:
tags:
- v*
workflow_dispatch:
inputs:
version:
description: The version to release, without the leading `v`.
type: string
required: true

env:
bot-name: nekit[bot]
bot-email: [email protected]
changelog: CHANGELOG-${{ inputs.version }}.md
python-version: "3.12"

jobs:
release:
name: Release
changelog:
runs-on: ubuntu-latest

permissions:
contents: write

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

- name: Setup Python ${{ env.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}

- name: Install Poetry
run: pipx install poetry

- name: Configure Poetry
run: poetry config virtualenvs.in-project true

- name: Specify the version
run: poetry env use python

- name: Install dependencies
run: poetry install --with release

- name: Build changelog ${{ inputs.version }}
run: poetry run changelogging preview > ${{ env.changelog }}

- name: Upload changelog ${{ inputs.version }}
uses: actions/upload-artifact@v4
with:
name: changelog
path: ${{ env.changelog }}

- name: Build changelog
run: poetry run changelogging build --stage --remove

- name: Setup bot user
run: |
git config --local user.name ${{ env.bot-name }}
git config --local user.email ${{ env.bot-email }}
- name: Commit and push
run: |
git commit -m "Add ${{ inputs.version }} to the changelog."
git push
tag:
runs-on: ubuntu-latest
needs: changelog

permissions:
contents: write

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

- name: Setup Python 3.12
- name: Setup bot user
run: |
git config --local user.name ${{ env.bot-name }}
git config --local user.email ${{ env.bot-email }}
- name: Tag and push
run: |
git tag v${{ inputs.version }}
git push --tags
publish:
runs-on: ubuntu-latest
needs: tag

permissions:
id-token: write

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

- name: Setup Python ${{ env.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: ${{ env.python-version }}

- name: Install Poetry
run: pipx install poetry
Expand All @@ -32,7 +113,39 @@ jobs:
- name: Build
run: poetry build

- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: packages
path: dist

- name: Publish to PyPI
run: poetry publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true

release:
runs-on: ubuntu-latest
needs: publish

steps:
- name: Download changelog
uses: actions/download-artifact@v4
with:
pattern: changelog
merge-multiple: true

- name: Download packages
uses: actions/download-artifact@v4
with:
pattern: packages
path: dist
merge-multiple: true

- name: Publish to GitHub
uses: softprops/action-gh-release@v2
with:
body_path: ${{ env.changelog }}
files: dist/*
tag_name: v${{ inputs.version }}
token: ${{ secrets.BOT_TOKEN }}
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ on:

jobs:
test:
name: Test
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Or by directly specifying it in the configuration like so:

```toml
[tool.poetry.dependencies]
entrypoint = "^2.0.3"
entrypoint = "^2.1.0"
```

Alternatively, you can add it directly from the source:
Expand Down
2 changes: 1 addition & 1 deletion entrypoint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def main() -> None:
__title__ = "entrypoint"
__author__ = "nekitdev"
__license__ = "MIT"
__version__ = "2.0.3"
__version__ = "2.1.0"

from entrypoint.core import MAIN, EntryPoint, Main, entrypoint, is_main

Expand Down
6 changes: 3 additions & 3 deletions entrypoint/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@


def is_main(name: str) -> bool:
"""Checks if the `name` is equal to `__main__`.
"""Checks if the `name` is equal to [`MAIN`][entrypoint.core.MAIN].
Arguments:
name: The name to check.
Returns:
Whether the `name` is equal to `__main__`.
Whether the `name` is equal to [`MAIN`][entrypoint.core.MAIN].
"""
return name == MAIN

Expand Down Expand Up @@ -56,7 +56,7 @@ def entrypoint(name: Optional[str] = None) -> EntryPoint:
Instead of applying dark magic, this function expects
callers to pass the `__name__` variable as an argument,
and merely checks it against `__main__` when needed.
and merely checks it against [`MAIN`][entrypoint.core.MAIN] when needed.
In case `__name__` is not provided, this function will attempt to read
the module name from the function given (via `__module__`).
Expand Down
45 changes: 18 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tool.poetry]
name = "entrypoint"
version = "2.0.3"
version = "2.1.0"
description = "Decorated functions as entry points."
authors = ["nekitdev"]
authors = ["nekitdev <[email protected]>"]
license = "MIT"

readme = "README.md"
Expand Down Expand Up @@ -35,39 +35,39 @@ python = ">= 3.8"
attrs = ">= 23.2.0"
named = ">= 1.4.2"

typing-aliases = ">= 1.8.0"
typing-aliases = ">= 1.10.1"

[tool.poetry.group.format.dependencies]
ruff = "0.3.3"
ruff = "0.4.9"

[tool.poetry.group.check.dependencies]
mypy = "1.9.0"
mypy = "1.10.0"

[tool.poetry.group.check.dependencies.pre-commit]
version = "3.6.2"
version = "3.7.1"
python = ">= 3.9"

[tool.poetry.group.test.dependencies]
coverage = "7.4.4"
pytest = "8.1.1"
pytest-cov = "4.1.0"
coverage = "7.5.3"
pytest = "8.2.2"
pytest-cov = "5.0.0"

[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
mkdocs = "1.5.3"
mkdocs-material = "9.5.13"
mkdocs = "1.6.0"
mkdocs-material = "9.5.27"

[tool.poetry.group.docs.dependencies.mkdocstrings]
version = "0.24.0"
version = "0.25.1"
extras = ["python"]

[tool.poetry.group.release]
optional = true

[tool.poetry.group.release.dependencies]
changelogging = "1.4.2"
changelogging = "2.3.0"

[tool.ruff]
line-length = 100
Expand Down Expand Up @@ -98,23 +98,14 @@ directory = "coverage"
[tool.mypy]
strict = true

[tool.changelogging]
[tool.changelogging.context]
name = "entrypoint"
version = "2.0.3"
version = "2.1.0"
url = "https://github.com/nekitdev/entrypoint"
directory = "changes"
output = "CHANGELOG.md"

start_string = "<!-- changelogging: start -->"

title_format = "{version} ({date})"
issue_format = "[#{issue}]({url}/pull/{issue})"

bullet = "-"
wrap = true
wrap_size = 100

display = ["feature", "change", "fix", "security", "deprecation", "removal", "internal"]
[tool.changelogging.formats]
title = "[{{version}}]({{url}}/tree/v{{version}}) ({{date}})"
fragment = "{{content}} ([#{{id}}]({{url}}/pull/{{id}}))"

[build-system]
requires = ["poetry-core >= 1.9.0"]
Expand Down
6 changes: 3 additions & 3 deletions tests/module.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from entrypoint import entrypoint

CALLED = 0
called = 0


@entrypoint()
def main() -> None:
global CALLED
global called

CALLED += 1
called += 1
2 changes: 1 addition & 1 deletion tests/test_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from entrypoint import is_main

CALLED = "CALLED"
CALLED = "called"

MAIN = "__main__"
TEST = "__test__"
Expand Down

0 comments on commit d269b4b

Please sign in to comment.