Skip to content

Commit f06afd5

Browse files
Prepare PyAutoPlot 1.1.1 with PyPI Trusted Publishing
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
1 parent aa866dd commit f06afd5

10 files changed

Lines changed: 869 additions & 611 deletions

File tree

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,76 @@
1-
name: Publish Python 🐍 distributions 📦 to PyPI
1+
name: Publish to PyPI
22

33
on:
44
push:
55
tags:
6-
- '*'
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
8+
permissions: {}
79

810
jobs:
9-
build-n-publish:
10-
name: Build and publish Python 🐍 distributions 📦 to PyPI
11+
build:
12+
name: Build and test distributions
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
env:
17+
MPLBACKEND: Agg
18+
steps:
19+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
20+
with:
21+
persist-credentials: false
22+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
23+
with:
24+
python-version: '3.12'
25+
- name: Build the wheel and source distribution
26+
run: |
27+
python -m pip install build twine
28+
python -m build
29+
- name: Check package metadata and release version
30+
run: |
31+
python -m twine check --strict dist/*
32+
python - <<'PY'
33+
import os
34+
from pathlib import Path
35+
from packaging.utils import parse_sdist_filename, parse_wheel_filename
36+
37+
tag = os.environ['GITHUB_REF_NAME']
38+
wheel, = Path('dist').glob('*.whl')
39+
sdist, = Path('dist').glob('*.tar.gz')
40+
for file, parse in [(wheel, parse_wheel_filename), (sdist, parse_sdist_filename)]:
41+
if str(parse(file.name)[1]) != tag:
42+
raise SystemExit(f'{file.name} does not match release tag {tag!r}')
43+
PY
44+
- name: Install the built wheel
45+
run: python -m pip install dist/*.whl
46+
- name: Test the installed wheel
47+
working-directory: ${{ runner.temp }}
48+
run: python -m unittest discover -s "$GITHUB_WORKSPACE/tests" -v
49+
- name: Upload distributions for the publish job
50+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
51+
with:
52+
name: distributions
53+
path: dist/
54+
if-no-files-found: error
55+
56+
publish:
57+
name: Publish distributions with attestations
58+
if: github.repository == 'Infinitode/PyAutoPlot'
59+
needs: build
1160
runs-on: ubuntu-latest
61+
permissions:
62+
id-token: write
63+
# No environment: the PyPI Trusted Publisher must also leave it blank.
1264
steps:
13-
- uses: actions/checkout@master
14-
- name: Set up Python 3.12
15-
uses: actions/setup-python@v3
16-
with:
17-
python-version: '3.12'
18-
- name: Install pypa/setuptools
19-
run: >-
20-
python -m
21-
pip install setuptools wheel
22-
- name: Extract tag name
23-
id: tag
24-
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)
25-
- name: Update version in setup.py
26-
run: >-
27-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py
28-
- name: Build a binary wheel
29-
run: >-
30-
python setup.py sdist bdist_wheel
31-
- name: Publish distribution 📦 to PyPI
32-
uses: pypa/gh-action-pypi-publish@master
33-
with:
34-
password: ${{ secrets.PYPI_API_TOKEN }}
65+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
66+
with:
67+
name: distributions
68+
path: dist/
69+
- name: Publish to PyPI
70+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
71+
with:
72+
attestations: true
73+
- name: Link to release provenance
74+
run: |
75+
printf '[View release provenance on PyPI](https://pypi.org/project/pyautoplot/%s/#security)\n' \
76+
"$GITHUB_REF_NAME" >> "$GITHUB_STEP_SUMMARY"

‎.github/workflows/tests.yml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: ['3.10', '3.14']
17+
env:
18+
MPLBACKEND: Agg
19+
steps:
20+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
21+
with:
22+
persist-credentials: false
23+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- run: python -m pip install .
27+
- run: python -m unittest discover -s tests -v

‎.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
__pycache__
22
*.pyc
3+
*.egg-info/
34
dist/
45
build/
6+
test_output/
57
venv/
6-
.venv/
8+
.venv/

‎CONTRIBUTING.md‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ Thank you for considering contributing to **PyAutoPlot**! Contributions, whether
1111
Ensure you have Python 3.6+ installed. You should also install compatible versions of the necessary dependencies for the project.
1212

1313
3. **Run Tests**
14-
Before making changes, run tests to confirm that everything works.
14+
Install the package and run the headless regression suite:
1515

16-
> [!TIP]
17-
> We sometimes include testing scripts in our projects for easy testing.
16+
```bash
17+
python -m pip install .
18+
python -m unittest discover -s tests -v
19+
```
20+
21+
`python test.py` is a separate smoke example using the included energy dataset.
1822

1923
## How to Contribute
2024

@@ -33,6 +37,29 @@ Thank you for considering contributing to **PyAutoPlot**! Contributions, whether
3337
- Submit a pull request with a detailed explanation of what you've changed or added.
3438
- Ensure your PR passes all automated tests and adheres to the contribution guidelines.
3539

40+
## Publishing a release
41+
42+
In the [`pyautoplot` project's publishing settings](https://pypi.org/manage/project/pyautoplot/settings/publishing/), add a **GitHub** Trusted Publisher with these values:
43+
44+
| PyPI field | Value |
45+
| --- | --- |
46+
| Owner | `Infinitode` |
47+
| Repository name | `PyAutoPlot` |
48+
| Workflow name | `build_and_publish.yml` |
49+
| Environment name | Leave blank |
50+
51+
The workflow does not use a GitHub environment or a PyPI API token. Because there is no environment approval step, limit GitHub write access to trusted maintainers and restrict who can create or modify release tags.
52+
53+
1. Update the version in `setup.py` and the release notes in `README.md`. Merge the release changes into `main` after CI passes.
54+
2. On the merged release commit, create and push a matching numeric tag (no `v` prefix). For 1.1.1:
55+
56+
```bash
57+
git tag 1.1.1
58+
git push origin refs/tags/1.1.1
59+
```
60+
61+
3. The **Publish to PyPI** workflow checks the tag against the built version and runs the regression suite against the wheel before publishing the wheel and source distribution. After publishing, follow the link in the workflow summary or the README's **PyPI provenance** badge to the **Security** tab on PyPI. Check that both files have a PyPI Publish attestation. Prior releases without attestations will not gain them retroactively.
62+
3663
## Community Guidelines
3764

3865
To maintain a positive and collaborative community, we ask that all contributors adhere to the following principles:

‎README.md‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@
44
![Downloads](https://pepy.tech/badge/pyautoplot)
55
![License Compliance](https://img.shields.io/badge/license-compliance-brightgreen.svg)
66
![PyPI Version](https://img.shields.io/pypi/v/pyautoplot)
7+
[![PyPI provenance](https://img.shields.io/badge/PyPI%20provenance-view-blue?logo=pypi)](https://pypi.org/project/pyautoplot/#security)
78

89
PyAutoPlot is an open-source Python library designed to make dataset analysis much easier by generating helpful detailed plots using `matplotlib`. It automatically generates appropriate plots based on the dataset you feed it.
910

11+
### Changes in version 1.1.1:
12+
- Fixed date detection and reports for sparse or mixed-format timestamps. Time plots use sorted timestamps as the x-axis for numeric measurements.
13+
- Fixed analysis and plotting for empty columns and header-only CSVs, and made JSON exports handle non-finite numbers.
14+
- Fixed partial themes and `dpi`/`bins` handling. Plots and reports no longer close figures they didn't create, and `show=False` supports file-only plotting.
15+
- Added regression tests and prepared releases for PyPI Trusted Publishing with per-file attestations. The provenance badge links to the latest release's provenance status on PyPI.
16+
1017
### Changes in version 1.1.0:
1118
1. **New Visualizations**: Added Correlation Heatmaps and Violin Plots.
1219
2. **Data Cleanup**: New `cleanup()` method allows filling or dropping missing values with multiple strategies.
@@ -89,10 +96,15 @@ from pyautoplot import AutoPlot
8996
# Initialize with a CSV file
9097
plotter = AutoPlot("path/to/dataset.csv")
9198

92-
# Automatically analyze and plot
93-
plotter.auto_plot(output_file='test', theme="dark", color='orange', excludes=['detailed_analysis'])
99+
# Save charts without opening plot windows
100+
plotter.auto_plot(
101+
output_file="charts.png", theme="dark", color="orange",
102+
excludes=["pairwise_scatter"], show=False, dpi=150, bins=20,
103+
)
94104
```
95105

106+
Date-like text columns are converted only if all their non-missing values parse. Offset-aware timestamps are normalized to UTC. When numeric measurements are present, line charts use the sorted timestamps as the x-axis; the area chart uses the first plottable date column and switches to an unstacked chart if a series has both positive and negative values.
107+
96108
> [!NOTE]
97109
> PyAutoPlot may not work well with certain datasets. If you find any issues please open an issue.
98110

0 commit comments

Comments
 (0)