You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Split the workflow into validation and release paths and add clearer step names and safeguards. PRs against main/master now run a validation matrix (3.10, 3.11, 3.12) that builds the package, runs twine check, and smoke-tests installing the wheel; fail-fast is disabled to surface version-specific issues. Tag pushes matching v*.*.* trigger a canonical release build (single Python 3.12) that produces dist artifacts, uploads them as workflow artifacts, and a separate publish job downloads those artifacts and uploads them to PyPI. Other improvements: minimal permissions (contents: read), explicit checkout/setup steps, pip caching enabled, comments for clarity, and use of --skip-existing when uploading to PyPI.
Copy file name to clipboardExpand all lines: .github/workflows/python-package.yml
+48-5Lines changed: 48 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,40 +1,62 @@
1
1
name: Build, validate & Release
2
2
3
+
# Usage:
4
+
# - For PRs: this workflow runs automatically to validate the package builds and installs correctly on multiple Python versions. No artifacts are published for PRs.
5
+
# - For releases: when you push a tag like v1.2.3, this workflow runs the full matrix validation, then builds the release artifacts, and finally publishes to PyPI if all checks pass.
6
+
3
7
on:
8
+
# Release pipeline: run only when pushing a version-like tag (e.g. v1.2.3)
4
9
push:
5
10
tags:
6
11
- "v*.*.*"
12
+
13
+
# Validation pipeline: run on PRs targeting main/master (no publishing)
7
14
pull_request:
8
15
branches: [main, master]
9
16
types: [opened, edited, synchronize, reopened]
10
17
18
+
# This workflow only needs to read repo contents
11
19
permissions:
12
20
contents: read
13
21
14
22
jobs:
15
23
test_matrix:
24
+
# PR + tag validation: ensure the project builds and installs on multiple Pythons
16
25
name: Test install & smoke (Py ${{ matrix.python-version }})
17
26
runs-on: ubuntu-latest
18
27
strategy:
28
+
# Run all versions even if one fails (helps spot version-specific issues)
19
29
fail-fast: false
20
30
matrix:
21
31
python-version: ["3.10", "3.11", "3.12"]
32
+
22
33
steps:
23
-
- uses: actions/checkout@v6
24
-
- uses: actions/setup-python@v6
34
+
# Fetch repository sources so we can build/test
35
+
- name: Checkout sources
36
+
uses: actions/checkout@v6
37
+
38
+
- name: Set up Python
39
+
uses: actions/setup-python@v6
25
40
with:
26
41
python-version: ${{ matrix.python-version }}
42
+
# Optional: cache pip downloads to speed up repeated runs
27
43
cache: pip
28
44
45
+
# Install packaging toolchain:
46
+
# - build: creates wheel + sdist
47
+
# - twine: validates metadata and can upload (upload only happens in publish job)
29
48
- name: Install build tools
30
49
run: python -m pip install -U pip build twine
31
50
51
+
# Build distributions just to verify packaging config works on this Python
0 commit comments