-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (63 loc) · 1.99 KB
/
python-publish.yml
File metadata and controls
67 lines (63 loc) · 1.99 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
name: Upload Python Package
on:
push:
branches: [ master ]
# O, si publicas solo con tag:
# tags: [ 'v*' ]
permissions:
contents: read
id-token: write # para Trusted Publishing
jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # <-- NECESARIO si usas setuptools_scm
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install build
run: python -m pip install --upgrade build
- name: Clean old artifacts
run: rm -rf dist build *.egg-info
- name: Build wheel and sdist
run: python -m build
- name: Show built versions (sanity check)
run: |
python - <<'PY'
import glob, zipfile
for whl in glob.glob('dist/*.whl'):
with zipfile.ZipFile(whl) as z:
meta = [n for n in z.namelist() if n.endswith('METADATA')][0]
data = z.read(meta).decode()
for line in data.splitlines():
if line.startswith('Name: ') or line.startswith('Version: '):
print(line)
PY
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
needs: [ build ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/sbxpy
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true # evita fallar si accidentalmente reconstruyes misma versión
verbose: true