Debian Codegraph @

.github/workflows/create-release.yml

raw
1 name: Create release
2
3 on:
4 push:
5 tags:
6 - "v*.*.*"
7 workflow_dispatch:
8
9 permissions:
10 contents: read
11
12 concurrency:
13 group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14 cancel-in-progress: true
15
16 env:
17 FORCE_COLOR: "1"
18 UV_SYSTEM_PYTHON: "1" # make uv do global installs
19
20 jobs:
21 publish-pypi:
22 runs-on: ubuntu-latest
23 name: PyPI Release
24 environment: release
25 if: github.repository_owner == 'sphinx-doc'
26 permissions:
27 attestations: write # for actions/attest
28 id-token: write # for actions/attest & PyPI trusted publishing
29 steps:
30 - uses: actions/checkout@v4
31 with:
32 persist-credentials: false
33 - name: Set up Python
34 uses: actions/setup-python@v5
35 with:
36 python-version: "3"
37 - name: Install uv
38 uses: astral-sh/setup-uv@v5
39 with:
40 version: latest
41 enable-cache: false
42
43 - name: Install build dependencies (pypa/build, twine)
44 run: uv pip install --group package
45
46 - name: Build distribution
47 run: python -m build
48
49 - name: Check distribution
50 run: twine check dist/*
51
52 - name: Create Sigstore attestations for built distributions
53 uses: actions/attest@v1
54 id: attest
55 with:
56 subject-path: "dist/*"
57 predicate-type: "https://docs.pypi.org/attestations/publish/v1"
58 predicate: "null"
59 show-summary: "true"
60
61 - name: Convert attestations to PEP 740
62 run: >
63 python utils/convert_attestations.py
64 "$BUNDLE_PATH"
65 "$SIGNER_IDENTITY"
66 env:
67 BUNDLE_PATH: "${{ steps.attest.outputs.bundle-path }}"
68 # workflow_ref example: sphinx-doc/sphinxext-opengraph/.github/workflows/create-release.yml@refs/heads/master
69 # this forms the "signer identity" for the attestations
70 SIGNER_IDENTITY: "https://github.com/${{ github.workflow_ref }}"
71
72 - name: Inspect PEP 740 attestations
73 run: pypi-attestations inspect dist/*.publish.attestation
74
75 - name: Prepare attestation bundles for uploading
76 run: |
77 mkdir -p /tmp/attestation-bundles
78 cp "$BUNDLE_PATH" /tmp/attestation-bundles/
79 cp dist/*.publish.attestation /tmp/attestation-bundles/
80 env:
81 BUNDLE_PATH: "${{ steps.attest.outputs.bundle-path }}"
82
83 - name: Upload attestation bundles
84 uses: actions/upload-artifact@v4
85 with:
86 name: attestation-bundles
87 path: /tmp/attestation-bundles/
88
89 - name: Upload to PyPI
90 env:
91 TWINE_NON_INTERACTIVE: "true"
92 run: |
93 twine upload dist/* --attestations --verbose
94
95 github-release:
96 runs-on: ubuntu-latest
97 name: GitHub release
98 environment: release
99 if: github.repository_owner == 'sphinx-doc'
100 permissions:
101 contents: write # for softprops/action-gh-release to create GitHub release
102 steps:
103 - uses: actions/checkout@v4
104 with:
105 persist-credentials: false
106 - name: Get release version
107 id: get_version
108 uses: actions/github-script@v7
109 with:
110 script: core.setOutput('version', context.ref.replace("refs/tags/v", ""))
111
112 - name: Create GitHub release
113 uses: softprops/action-gh-release@v2
114 if: startsWith(github.ref, 'refs/tags/')
115 with:
116 name: "sphinxext-opengraph ${{ steps.get_version.outputs.version }}"
117 body: ""