aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/publish.yml
blob: 552aaa74ea50edec4220831066e027f744a16feb (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

# Publishes to PyPI when a GitHub release is published.
#
# No token is stored anywhere: PyPI trusts this workflow through OIDC
# (trusted publishing). On pypi.org a "pending publisher" must have been
# registered with exactly these four values:
#
#   Owner        ElvisClaros
#   Repository   claude-logbook
#   Workflow     publish.yml
#   Environment  pypi
#
# If any of them does not match, PyPI rejects the 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 # the only thing trusted publishing needs

    steps:
      - uses: actions/checkout@v4

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

      # The number lives in claude_logbook/__init__.py and it is easy to forget
      # to bump it. Better to fail here than publish something mislabelled: a
      # version uploaded to PyPI can never be replaced, only yanked.
      - name: Tag matches __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: Artifacts are sound
        run: |
          python -m pip install --upgrade twine
          twine check dist/*

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