aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/publish.yml
blob: 4fc675c67e20e99ace07497e795da0bbd9d25812 (plain)
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
name: Publish

# Publica en PyPI cuando se publica un release de GitHub.
#
# No hay ningún token guardado: PyPI confía en este workflow por OIDC
# (trusted publishing). Del lado de pypi.org hay que haber dado de alta un
# "pending publisher" con exactamente estos cuatro datos:
#
#   Owner        ElvisClaros
#   Repository   claude-logbook
#   Workflow     publish.yml
#   Environment  pypi
#
# Si alguno no coincide, PyPI rechaza el upload.

on:
  release:
    types: [published]

permissions: {}

jobs:
  publish:
    runs-on: ubuntu-latest

    environment:
      name: pypi
      url: https://pypi.org/p/claude-logbook

    permissions:
      id-token: write # lo único que habilita el trusted publishing

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: "3.13"

      # El número vive en claude_logbook/__init__.py y es fácil olvidarse de
      # subirlo. Mejor fallar acá que publicar algo mal rotulado: una versión
      # subida a PyPI no se puede reemplazar nunca, solo yankear.
      - name: El tag coincide con __version__
        run: |
          tag="${GITHUB_REF_NAME#v}"
          ver="$(python -c 'import claude_logbook; print(claude_logbook.__version__)')"
          echo "tag=$tag  __version__=$ver"
          test "$tag" = "$ver"

      - name: Build
        run: |
          python -m pip install --upgrade build
          python -m build

      - name: Los artefactos están sanos
        run: |
          python -m pip install --upgrade twine
          twine check dist/*

      - uses: pypa/gh-action-pypi-publish@release/v1