diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aa290117..27cd6f50 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,8 +8,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - - uses: WIPACrepo/wipac-dev-flake8-action@v1 + - uses: actions/setup-python@v4 + - uses: WIPACrepo/wipac-dev-flake8-action@v1.0 mypy: runs-on: ubuntu-latest @@ -18,7 +18,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.10' - - uses: WIPACrepo/wipac-dev-mypy-action@v1.1 + - uses: WIPACrepo/wipac-dev-mypy-action@v1.2 setup_builder: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 90de95aa..710d5def 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # WIPACrepo/wipac-dev-py-setup-action -GitHub Action Package for Automating Python-Package Setup +GitHub Action Package for Automating Python-Package Setup & Maintenance @@ -7,7 +7,11 @@ GitHub Action Package for Automating Python-Package Setup This GitHub Action prepares a repository to be GitHub-released and PyPI-published by the [Python Semantic Release GitHub Action](https://python-semantic-release.readthedocs.io/en/latest/). All that a user needs to do is define a few attributes in `setup.cfg` (see [*Main Configuration Modes*](#main-configuration-modes)). ### Details -`setup.cfg` sections needed for publishing a package to PyPI are auto-generated, hyper-linked badges are added to the `README.md`, and the root directory's `requirements.txt` is overwritten/updated (by way of [pip-compile](https://github.com/jazzband/pip-tools)). Commits are git-pushed by the "github-actions" bot (github-actions@github.com) by default, or your chosen actor configured by inputs (`git_committer_name` & `git_committer_email`). +- `setup.cfg` sections needed for publishing a package to PyPI are auto-generated, +- hyper-linked badges are added to the `README.md`, +- the root directory's `requirements.txt` is overwritten/updated (by way of [pip-compile](https://github.com/jazzband/pip-tools)) along with dedicated `requirements-EXTRA.txt` files for each package "extra", and +- `py.typed` files are created as needed. +Commits are git-pushed by the "github-actions" bot (github-actions@github.com) by default, or your chosen actor configured by inputs (`git_committer_name` & `git_committer_email`). #### GitHub Action Syntax ``` diff --git a/action.yml b/action.yml index 407ec9cf..780acf14 100644 --- a/action.yml +++ b/action.yml @@ -61,6 +61,33 @@ runs: git commit -m " update README.md" || true shell: bash + - name: Add py.typed file(s) (and commit) + run: | + python -c ' + import os + from pathlib import Path + + line_to_parse = "" + with open("setup.cfg") as f: + for line in f.readlines(): + if line.startswith("version_variable = "): + line_to_parse = line.strip() # remove newline + if not line_to_parse: + raise Exception("Cannot addd py.typed files (missing version_variable in setup.cfg)") + + for version_path in line_to_parse.removeprefix("version_variable = ").split(","): + print(version_path) + dpath = version_path.removesuffix("__init__.py:__version__") + print(dpath) + fpath = Path(dpath) / "py.typed" + print(fpath) + fpath.touch() # create if needed! + ' + git add . # won't error if nothing to add + git commit -m " add py.typed file(s)" || true + + shell: bash + - name: Build requirements.txt (and commit) run: | pip3 install pip-tools