Skip to content

Commit 86691a4

Browse files
committed
Adds a minimal release workflow and migrated to uv.
1 parent e23cee4 commit 86691a4

File tree

6 files changed

+712
-30
lines changed

6 files changed

+712
-30
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,41 @@ jobs:
2323

2424
steps:
2525
- uses: actions/checkout@v5
26-
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v5
26+
- name: Install uv and set the Python version
27+
uses: astral-sh/setup-uv@v6
2828
with:
2929
python-version: ${{ matrix.python-version }}
30+
enable-cache: true
3031
- name: Install dependencies
3132
run: |
32-
python -m pip install --upgrade pip
33-
pip install .[dev]
34-
35-
- name: Run tests
33+
uv sync --frozen --all-extras --dev
34+
- name: Run tests with coverage
3635
run: |
37-
pytest -v --cov=mediafile --cov=mediafile --cov-report=xml --cov-report=html test/
36+
uv run poe test-with-coverage -v
3837
- name: Upload coverage reports
3938
if: matrix.os == 'ubuntu-24.04' && matrix.python-version == env.MAIN_PYTHON_VERSION
4039
uses: actions/upload-artifact@v4
4140
with:
4241
name: coverage-${{ github.run_id }}
43-
path: htmlcov/
42+
path: reports
4443
retention-days: 30
4544

4645
style:
4746
name: Style
4847
runs-on: ubuntu-latest
4948
steps:
5049
- uses: actions/checkout@v5
51-
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
52-
uses: actions/setup-python@v5
50+
- name: Install uv and set the Python version
51+
uses: astral-sh/setup-uv@v6
5352
with:
5453
python-version: ${{ env.MAIN_PYTHON_VERSION }}
54+
enable-cache: true
5555
- name: Install dependencies
5656
run: |
57-
python -m pip install --upgrade pip
58-
pip install .[dev]
57+
uv sync --frozen --group dev
5958
- name: Check style with Ruff
6059
run: |
61-
ruff check --output-format=github .
60+
uv run ruff check --output-format=github .
6261
- name: Check format with Ruff
6362
run: |
64-
ruff format --check .
63+
uv run ruff format --check .
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Publish Python Package
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version of the new release, just as a number with no prepended "v"'
8+
required: true
9+
10+
env:
11+
PYTHON_VERSION: "3.12"
12+
NEW_VERSION: ${{ inputs.version }}
13+
NEW_TAG: v${{ inputs.version }}
14+
15+
jobs:
16+
increment-version:
17+
name: Bump version, commit and create tag
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v5
21+
- name: Install uv and set the Python version
22+
uses: astral-sh/setup-uv@v6
23+
with:
24+
python-version: ${{ env.PYTHON_VERSION }}
25+
enable-cache: true
26+
- name: Bump project version
27+
run: uv version "${{ env.NEW_VERSION }}"
28+
29+
- uses: EndBug/add-and-commit@v9
30+
id: commit_and_tag
31+
name: Commit the changes and create tag
32+
with:
33+
message: "Increment version to ${{ env.NEW_VERSION }}"
34+
tag: "${{ env.NEW_TAG }} --force"
35+
36+
build:
37+
name: Build the distribution package
38+
runs-on: ubuntu-latest
39+
needs: increment-version
40+
steps:
41+
- uses: actions/checkout@v5
42+
- name: Install uv and set the Python version
43+
uses: astral-sh/setup-uv@v6
44+
with:
45+
python-version: ${{ env.PYTHON_VERSION }}
46+
enable-cache: true
47+
48+
- name: Build a binary wheel and a source tarball
49+
run: uv build
50+
51+
- name: Store the package
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: python-package-distributions
55+
path: dist/
56+
57+
publish-to-pypi:
58+
name: Publish distribution 📦 to PyPI
59+
runs-on: ubuntu-latest
60+
needs: build
61+
environment:
62+
name: pypi
63+
url: https://pypi.org/p/mediafile
64+
permissions:
65+
id-token: write
66+
steps:
67+
- name: Download all the dists
68+
uses: actions/download-artifact@v5
69+
with:
70+
name: python-package-distributions
71+
path: dist/
72+
- name: Publish
73+
run: uv publish

CONTRIBUTING.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,22 @@ Please follow these guidelines to ensure a smooth contribution process.
1111

1212
## Setup the Development Environment
1313

14-
We recommend using a virtual environment to manage dependencies. You can use `venv`, `conda`, or any other tool of your choice.
15-
1614
1. Fork/Clone the repository on GitHub
1715
```bash
1816
git clone <your-fork-url>
1917
cd mediafile
2018
```
21-
2. Install dependencies and set up the development environment
19+
20+
We use `uv` to manage virtual environments. If you don't have it installed, see [here](https://pypi.org/project/uv/).
21+
22+
2. Install dependencies and set up the development environment (using same lockfile as production):
23+
```bash
24+
uv sync --frozen --group dev
25+
```
26+
27+
3. Activate the virtual environment (optional):
2228
```bash
23-
pip install -e '.[dev]'
29+
source .venv/bin/activate
2430
```
2531

2632
## Before submitting a Pull Request
@@ -29,7 +35,7 @@ Verify that your code adheres to the project standards and conventions. Run
2935
ruff and pytest to ensure your code is properly formatted and all tests pass.
3036

3137
```bash
32-
ruff check .
33-
ruff format .
34-
pytest .
38+
uv run poe format
39+
uv run poe lint
40+
uv run poe test
3541
```

mediafile/__version__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyproject.toml

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ build-backend = "flit_core.buildapi"
44

55
[project]
66
name = "mediafile"
7+
version = "1.0.0a1"
78
authors = [
89
{ name = "Adrian Sampson", email = "[email protected]" },
910
]
1011
readme = "README.rst"
1112
license = "MIT"
1213
requires-python = ">=3.9"
1314
description = "A simple, cross-format library for reading and writing media file metadata."
14-
dynamic = ["version"]
1515
classifiers = [
1616
'Topic :: Multimedia :: Sound/Audio',
1717
'Environment :: Web Environment',
@@ -32,12 +32,6 @@ dependencies = [
3232
Documentation = "https://mediafile.readthedocs.io"
3333
Source = "https://github.com/beetbox/mediafile"
3434

35-
[project.optional-dependencies]
36-
dev = [
37-
"ruff",
38-
"pytest",
39-
"pytest-cov"
40-
]
4135

4236
[tool.ruff]
4337
target-version = "py39"
@@ -58,4 +52,47 @@ ignore = [
5852
]
5953

6054
[tool.ruff.format]
61-
quote-style = "double"
55+
quote-style = "double"
56+
57+
[dependency-groups]
58+
dev = [
59+
"poethepoet>=0.37.0",
60+
"pytest>=8.4.2",
61+
"pytest-cov>=7.0.0",
62+
"ruff>=0.14.1",
63+
]
64+
65+
[tool.poe]
66+
executor.type = "uv"
67+
68+
[tool.poe.tasks.build]
69+
help = "Build the package"
70+
cmd = "uv build"
71+
72+
[tool.poe.tasks.test]
73+
help = "Run the test suite with coverage"
74+
cmd = "pytest $OPTS"
75+
env.OPTS.default = "---cov=mediafile test/"
76+
77+
[tool.poe.tasks.test-with-coverage]
78+
help = "Run the test suite with coverage (alias for 'poe test')"
79+
ref = "test"
80+
env.OPTS.default = """
81+
--cov=mediafile
82+
--cov-report=xml:.reports/coverage.xml
83+
--cov-report=html:.reports/html
84+
--cov-branch
85+
--cov-context=test
86+
"""
87+
88+
[tool.poe.tasks.lint]
89+
help = "Run ruff linter"
90+
cmd = "ruff check"
91+
92+
[tool.poe.tasks.format]
93+
help = "Autoformat code with ruff"
94+
cmd = "ruff format"
95+
96+
[tool.poe.tasks.check-types]
97+
help = "Check the code for typing issues. Accepts mypy options."
98+
cmd = "mypy"

0 commit comments

Comments
 (0)