Skip to content

Commit 8e74d1a

Browse files
committed
Added workflow for release and build workflow now uses uv.
1 parent a3a5d27 commit 8e74d1a

File tree

3 files changed

+147
-48
lines changed

3 files changed

+147
-48
lines changed

.github/workflows/build.yml

Lines changed: 73 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,81 @@
11
name: Build
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
8-
branches:
9-
- master
10-
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
1110
env:
12-
MAIN_PYTHON_VERSION: "3.12"
11+
MAIN_PYTHON_VERSION: "3.12"
12+
13+
concurrency:
14+
# Cancel previous workflow run when a new commit is pushed to a feature branch
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
1317

1418
jobs:
15-
test:
16-
name: "${{ matrix.os }}: ${{ matrix.python-version }}"
17-
runs-on: ${{ matrix.os }}
18-
strategy:
19-
fail-fast: false
20-
matrix:
21-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
22-
os: [ubuntu-24.04, windows-latest]
19+
changed-files:
20+
runs-on: ubuntu-latest
21+
name: Get changed files
22+
steps:
23+
- uses: actions/checkout@v5
24+
25+
- name: Get changed python files
26+
id: raw-changed-python-files
27+
uses: tj-actions/changed-files@v46
28+
with:
29+
files: |
30+
**.py
31+
uv.lock
32+
33+
test:
34+
name: "${{ matrix.os }}: ${{ matrix.python-version }}"
35+
runs-on: ${{ matrix.os }}
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
40+
os: [ubuntu-24.04, windows-latest]
2341

24-
steps:
25-
- uses: actions/checkout@v5
26-
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v5
28-
with:
29-
python-version: ${{ matrix.python-version }}
30-
- name: Install dependencies
31-
run: |
32-
python -m pip install --upgrade pip
33-
pip install .[dev]
42+
steps:
43+
- uses: actions/checkout@v5
44+
- name: Install uv and set the Python version
45+
uses: astral-sh/setup-uv@v6
46+
with:
47+
python-version: ${{ matrix.python-version }}
48+
enable-cache: true
49+
- name: Install dependencies
50+
run: |
51+
uv sync --frozen --all-extras --dev
52+
- name: Run tests with coverage
53+
run: |
54+
uv run poe test-with-coverage -v
55+
- name: Upload coverage reports
56+
if: matrix.os == 'ubuntu-24.04' && matrix.python-version == env.MAIN_PYTHON_VERSION
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: coverage-${{ github.run_id }}
60+
path: reports
61+
retention-days: 30
3462

35-
- name: Run tests
36-
run: |
37-
pytest -v
38-
style:
39-
name: Style
40-
runs-on: ubuntu-latest
41-
steps:
42-
- uses: actions/checkout@v5
43-
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
44-
uses: actions/setup-python@v5
45-
with:
46-
python-version: ${{ env.MAIN_PYTHON_VERSION }}
47-
- name: Install dependencies
48-
run: |
49-
python -m pip install --upgrade pip
50-
pip install .[dev]
51-
- name: Check style with Ruff
52-
run: |
53-
ruff check --output-format=github .
54-
- name: Check format with Ruff
55-
run: |
56-
ruff format --check .
63+
style:
64+
name: Style
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v5
68+
- name: Install uv and set the Python version
69+
uses: astral-sh/setup-uv@v6
70+
with:
71+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
72+
enable-cache: true
73+
- name: Install dependencies
74+
run: |
75+
uv sync --frozen --group dev
76+
- name: Check style with Ruff
77+
run: |
78+
uv run ruff check --output-format=github
79+
- name: Check format with Ruff
80+
run: |
81+
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

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Upcoming
1010
the codebase with ``ruff``.
1111
- Moved changelog into its own file, ``changelog.rst``. Also added github workflow
1212
for automatic changelog reminders.
13+
- The project now uses ``uv`` for dependency management.
1314

1415
v0.13.0
1516
'''''''

0 commit comments

Comments
 (0)