Debian Codegraph @

.github/workflows/publish.yml

raw
1 name: Publish to PyPI
2
3 on:
4 push:
5 tags:
6 - "v*"
7 workflow_dispatch:
8 inputs:
9 test-pypi-only:
10 description: "Publish to Test PyPI only"
11 type: boolean
12 default: true
13
14 permissions:
15 contents: read
16
17 jobs:
18 build:
19 name: "Build dists"
20 runs-on: "ubuntu-latest"
21 outputs:
22 artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
23
24 steps:
25 - name: "Checkout repository"
26 uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2
27 with:
28 persist-credentials: false
29
30 - name: "Setup Python"
31 uses: "actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405" # v6.2.0
32 with:
33 python-version: "3.x"
34
35 - name: "Install dependencies"
36 run: python -m pip install build==1.4.0
37
38 - name: "Build dists"
39 run: |
40 SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) \
41 python -m build
42
43 - name: "Upload dists"
44 uses: "actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f"
45 id: upload-artifact
46 with:
47 name: "dist"
48 path: "dist/"
49 if-no-files-found: error
50 retention-days: 5
51
52 publish:
53 name: "Publish"
54 if: startsWith(github.ref, 'refs/tags/')
55 needs: ["build"]
56 permissions:
57 id-token: write
58 runs-on: "ubuntu-latest"
59 environment:
60 name: "publish"
61
62 steps:
63 - name: "Download dists"
64 uses: "actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3" # v8.0.0
65 with:
66 artifact-ids: ${{ needs.build.outputs.artifact-id }}
67 path: "dist/"
68
69 - name: "Publish dists to PyPI"
70 uses: "pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b" # v1.14.0
71 with:
72 attestations: true
73
74 publish-test-pypi:
75 name: "Publish to Test PyPI"
76 if: github.event_name == 'workflow_dispatch'
77 needs: ["build"]
78 permissions:
79 id-token: write
80 runs-on: "ubuntu-latest"
81 environment:
82 name: "testpypi"
83
84 steps:
85 - name: "Download dists"
86 uses: "actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3" # v8.0.0
87 with:
88 artifact-ids: ${{ needs.build.outputs.artifact-id }}
89 path: "dist/"
90
91 - name: "Publish dists to Test PyPI"
92 uses: "pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b" # v1.14.0
93 with:
94 repository-url: https://test.pypi.org/legacy/
95 attestations: true