update master #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |