Skip to content

Commit 7cf3595

Browse files
committed
ci: dynamic versioning and automated releases
1 parent e477237 commit 7cf3595

9 files changed

Lines changed: 123 additions & 544 deletions

File tree

.github/workflows/publish.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Upload Python Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
environment: production
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.x'
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
python -m pip install ".[dev]"
21+
- name: Run tests
22+
run: |
23+
dev lint
24+
dev test
25+
- name: Build package
26+
run: python -m build --sdist --wheel
27+
- name: Publish package
28+
uses: pypa/gh-action-pypi-publish@release/v1
29+
with:
30+
user: __token__
31+
password: ${{ secrets.PYPI_DEPLOYMENT_TOKEN }}

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to
66
[Semantic Versioning](http://semver.org/).
77

8+
## [1.0.1] - 2023-09-24
9+
10+
### Added
11+
12+
- Build system requirements: `setuptools_scm[toml] >=8.0`, `wheel`
13+
- Dynamic version using [setuptools_scm](https://pypi.org/project/setuptools-scm/)
14+
- Version specifiers for dependencies and dev dependencies
15+
- GitHub Actions publish workflow, triggered when release is published
16+
17+
### Changed
18+
19+
- Added dynamic badges to `README.md`
20+
- Updated `CONTRIBUTING.md` instructions for setting up local development environment
21+
22+
### Removed
23+
24+
- Static version in `pyproject.toml`
25+
- Optional dev dependency: `pip-tools`
26+
- Superfluous `requirements.txt` and `requirements-dev.txt` files
27+
- Dev scripts for `pip-compile` and `pip-sync` commands
28+
829
## [1.0.0] - 2023-09-23
930

1031
### Added

CONTRIBUTING.md

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
First off, thanks for taking the time to contribute! ❤️
55

6-
All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways
7-
to help and details about how this project handles them. Please make sure to read the relevant section before making
8-
your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The
9-
community looks forward to your contributions. 🎉
6+
All types of contributions are encouraged and valued. See the [Table of Contents] for different ways to help and details
7+
about how this project handles them. Please make sure to read the relevant section before making your contribution. It
8+
will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward
9+
to your contributions. 🎉
1010

1111
> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support
1212
the project and show your appreciation, which we would also be very happy about:
@@ -18,15 +18,15 @@ the project and show your appreciation, which we would also be very happy about:
1818
<!-- omit in toc -->
1919
## Table of Contents
2020

21-
- [Code of Conduct](#code-of-conduct)
22-
- [I Have a Question](#i-have-a-question)
23-
- [I Want To Contribute](#i-want-to-contribute)
24-
- [Reporting Bugs](#reporting-bugs)
25-
- [Suggesting Enhancements](#suggesting-enhancements)
26-
- [Your First Code Contribution](#your-first-code-contribution)
27-
- [Improving The Documentation](#improving-the-documentation)
28-
- [Styleguide](#styleguide)
29-
- [Commit Messages](#commit-messages)
21+
- [Code of Conduct]
22+
- [I Have a Question]
23+
- [I Want To Contribute]
24+
- [Reporting Bugs]
25+
- [Suggesting Enhancements]
26+
- [Your First Code Contribution]
27+
- [Improving The Documentation]
28+
- [Styleguide]
29+
- [Commit Messages]
3030

3131
## Code of Conduct
3232

@@ -104,7 +104,7 @@ Once it's filed:
104104
obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with
105105
the `needs-repro` tag will not be addressed until they are reproduced.
106106
- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as
107-
`critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution).
107+
`critical`), and the issue will be left to be [implemented by someone].
108108

109109
### Suggesting Enhancements
110110

@@ -118,7 +118,7 @@ the community to understand your suggestion and find related suggestions.
118118
- Make sure that you are using the latest version.
119119
- Read the [documentation] carefully and find out if the functionality is already covered, maybe by an individual
120120
configuration.
121-
- Perform a [search] to see if the enhancement has already been suggested. If it has, add a comment to the existing
121+
- Search [Discussions] to see if the enhancement has already been suggested. If it has, add a comment to the existing
122122
issue instead of opening a new one.
123123
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to
124124
convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful
@@ -128,9 +128,9 @@ an add-on/plugin library.
128128
<!-- omit in toc -->
129129
#### How Do I Submit a Good Enhancement Suggestion?
130130

131-
Enhancement suggestions are tracked as GitHub [issues].
131+
Enhancement suggestions are tracked as GitHub [Discussions].
132132

133-
- Use a **clear and descriptive title** for the issue to identify the suggestion.
133+
- Use a **clear and descriptive title** to identify your suggestion.
134134
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
135135
- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point
136136
you can also tell which alternatives do not work for you.
@@ -154,15 +154,12 @@ To get started, you'll need to clone the git repository and set up your local de
154154
2. Change to the project directory: `cd python-dev-cli`
155155
3. Create a virtual environment: `python -m venv venv`
156156
4. Activate the virtual environment: `source venv/bin/activate` (or `venv\Scripts\activate.bat` on Windows)
157-
5. Install dev dependencies: `pip install --no-deps -r requirements-dev.txt`
157+
5. Install dev dependencies: `pip install -e ".[dev]"`
158158
6. Install git pre-commit hooks: `pre-commit install`
159-
7. Install the `dev` CLI in editable mode: `pip install -e .`
160-
8. Run tests: `dev test`
159+
7. View available scripts: `dev -h`
161160

162-
This project uses the `pyproject.toml` file and [pip-tools] to manage dependencies. Generally, you should avoid adding
163-
new dependencies to the project, but if it is necessary you should add it to the `pyproject.toml` file and then run
164-
`dev compile` to update the `requirements.txt` (or `dev compile_dev` to update the `requirements-dev.txt` file, if it is
165-
a dev dependency). You can then run `dev sync` to install the new dependency in your virtual environment.
161+
This project uses the `pyproject.toml` file to manage dependencies. Generally, you should avoid adding new dependencies
162+
to the project, but if it is necessary you should add them to the `pyproject.toml` file and then run `dev install`.
166163

167164
### Improving The Documentation
168165

@@ -196,12 +193,23 @@ This guide is based on the **contributing-gen**. [Make your own](https://github.
196193

197194
[Black]: https://black.readthedocs.io/en/stable/the_black_code_style/index.html
198195
[bug tracker]: https://github.com/sscovil/devissues?q=label%3Abug
196+
[Code of Conduct]: https://github.com/sscovil/python-dev-cli/blob/main/CONTRIBUTING.md#code-of-conduct
197+
[Commit Messages]: https://github.com/sscovil/python-dev-cli/blob/main/CONTRIBUTING.md#commit-messages
199198
[Conventional Commits]: https://www.conventionalcommits.org/en/v1.0.0/
199+
[Discussions]: https://github.com/sscovil/python-dev-cli/discussions
200200
[documentation]: https://github.com/sscovil/python-dev-cli/blob/main/README.md
201201
[GitHub flow]: https://docs.github.com/en/get-started/quickstart/github-flow
202+
[I Have a Question]: https://github.com/sscovil/python-dev-cli/blob/main/CONTRIBUTING.md#i-have-a-question
203+
[I Want To Contribute]: https://github.com/sscovil/python-dev-cli/blob/main/CONTRIBUTING.md#i-want-to-contribute
204+
[implemented by someone]: https://github.com/sscovil/python-dev-cli/blob/main/CONTRIBUTING.md#your-first-code-contribution
205+
[Improving The Documentation]: https://github.com/sscovil/python-dev-cli/blob/main/CONTRIBUTING.md#improving-the-documentation
202206
[issue]: https://github.com/sscovil/python-dev-cli/issues/new
203207
[issues]: https://github.com/sscovil/python-dev-cli/issues
204208
[pip-tools]: https://github.com/jazzband/pip-tools
205209
[Python Developer CLI Code of Conduct]: https://github.com/sscovil/devblob/master/CODE_OF_CONDUCT.md
210+
[Reporting Bugs]: https://github.com/sscovil/python-dev-cli/blob/main/CONTRIBUTING.md#reporting-bugs
206211
[Ruff]: https://docs.astral.sh/ruff/
207-
[search]: https://github.com/sscovil/python-dev-cli/issues
212+
[Table of Contents]: https://github.com/sscovil/python-dev-cli/blob/main/CONTRIBUTING.md#table-of-contents
213+
[Styleguide]: https://github.com/sscovil/python-dev-cli/blob/main/CONTRIBUTING.md#styleguide
214+
[Suggesting Enhancements]: https://github.com/sscovil/python-dev-cli/blob/main/CONTRIBUTING.md#suggesting-enhancements
215+
[Your First Code Contribution]: https://github.com/sscovil/python-dev-cli/blob/main/CONTRIBUTING.md#your-first-code-contribution

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Python Developer CLI
22

3+
![PyPI - Version](https://img.shields.io/pypi/v/python-dev-cli)
4+
![PyPI - License](https://img.shields.io/pypi/l/python-dev-cli)
5+
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/python-dev-cli)
6+
![GitHub issues](https://img.shields.io/github/issues/sscovil/python-dev-cli?link=https%3A%2F%2Fgithub.com%2Fsscovil%2Fpython-dev-cli%2Fissues)
7+
![GitHub issues by-label](https://img.shields.io/github/issues/sscovil/python-dev-cli/bug?link=https%3A%2F%2Fgithub.com%2Fsscovil%2Fpython-dev-cli%2Flabels%2Fbug)
8+
39
Python developer CLI enables you to run custom scripts defined in your [pyproject.toml] file, eliminating the need for
410
shell scripts and Makefiles, and reducing extraneous cognitive load on your teammates and contributors.
511

@@ -128,7 +134,7 @@ dev other_scripts
128134
# foobar
129135
```
130136

131-
Script template functionality can be disabled, if you prefer to keep things simple. See the [Settings](#settings)
137+
Script template functionality can be disabled, if you prefer to keep things simple. See the [Settings]
132138
section below for more information.
133139

134140
## Settings
@@ -340,4 +346,5 @@ page.
340346
[Contributor Covenant]: https://contributor-covenant.org/
341347
[Jinja2]: https://jinja.palletsprojects.com/en/3.0.x/
342348
[pyproject.toml]: https://peps.python.org/pep-0518/#tool-table
349+
[Settings]: https://github.com/sscovil/python-dev-cli/blob/main/README.md#settings
343350
[subprocess.run()]: https://docs.python.org/3/library/subprocess.html#subprocess.run

pyproject.toml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[build-system]
2-
requires = ["setuptools"]
2+
requires = ["setuptools >=65", "setuptools_scm[toml] >=8.0", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "python-dev-cli"
7-
version = "1.0.0"
7+
dynamic = ["version"]
88
description = "Python developer CLI for running custom scripts defined in pyproject.toml"
9-
authors = [{ name = "Shaun Scovil", email = "sscovil@pythondevcli.io" }]
9+
authors = [{name = "Shaun Scovil", email = "sscovil@pythondevcli.io"}]
1010
readme = "README.md"
11-
license = { text = "BSD" }
11+
license = {text = "BSD"}
1212
requires-python = ">=3.11"
13-
keywords = ["python", "dev", "cli", "scripts", "pyproject.toml", "automation"]
13+
keywords = ["dev", "cli", "scripts", "automation", "config", "pyproject.toml"]
1414
classifiers = [
1515
"Development Status :: 5 - Production/Stable",
1616
"Environment :: Console",
@@ -34,7 +34,7 @@ classifiers = [
3434
"Topic :: Utilities",
3535
"Typing :: Typed",
3636
]
37-
dependencies = ["jinja2"]
37+
dependencies = ["jinja2 ~=3.1.2"]
3838

3939
[project.scripts]
4040
dev = "python_dev_cli.cli:dev_cli"
@@ -47,7 +47,7 @@ Issues = "https://github.com/sscovil/python-dev-cli/issues"
4747
Changelog = "https://github.com/sscovil/python-dev-cli/blob/main/CHANGELOG.md"
4848

4949
[project.optional-dependencies]
50-
dev = ["black", "build", "pip-tools", "pre-commit", "ruff", "twine"]
50+
dev = ["black ~=23.9.1", "build ~=1.0.3", "pre-commit ~=3.4.0", "ruff ~=0.0.291", "twine ~=4.0.2"]
5151

5252
[tool.black]
5353
exclude = "venv"
@@ -60,22 +60,18 @@ include = ["os"]
6060
[tool.python-dev-cli.scripts]
6161
black = "black --check --config pyproject.toml ."
6262
black_fix = "black --config pyproject.toml ."
63-
build = "python3 -m build"
63+
build = "python3 -m build --sdist --wheel"
6464
clean = "rm -rf build dist"
6565
clean_build = ["clean", "build"]
66-
compile = "pip-compile -o requirements.txt pyproject.toml"
67-
compile_dev = "pip-compile -o requirements-dev.txt --extra dev pyproject.toml"
68-
install_editable = "python3 -m pip install -e ."
66+
install = "python3 -m pip install -e \".[dev]\""
67+
install_test = "python3 -m pip install --upgrade --index-url https://test.pypi.org/simple/ --no-deps --no-cache-dir python-dev-cli"
6968
lint = ["black", "ruff"]
7069
lint_fix = ["black_fix", "ruff_fix"]
7170
ruff = "ruff --config pyproject.toml ."
7271
ruff_fix = "ruff --fix --exit-non-zero-on-fix --config pyproject.toml ."
73-
sync = ["sync_dev", "install_editable"]
74-
sync_dev = "pip-sync requirements-dev.txt"
7572
test = "python3 -m unittest discover test *_test.py --locals -bcf"
76-
test_install = "python3 -m pip install --upgrade --index-url https://test.pypi.org/simple/ --no-deps --no-cache-dir python-dev-cli"
77-
test_upload = "python3 -m twine upload --skip-existing --repository testpypi dist/*"
7873
upload = "python3 -m twine upload --skip-existing dist/*"
74+
upload_test = "python3 -m twine upload --skip-existing --repository testpypi dist/*"
7975

8076
[tool.pip-tools]
8177
allow-unsafe = true
@@ -87,4 +83,7 @@ line-length = 120
8783
exclude = ["venv"]
8884

8985
[tool.setuptools]
90-
package-dir = { "" = "src" }
86+
package-dir = {"" = "src"}
87+
88+
[tool.setuptools_scm]
89+
write_to = "src/python_dev_cli/_version.py"

0 commit comments

Comments
 (0)