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