Debian Codegraph @

.github/workflows/cd.yml

raw
1 name: CD
2
3 on:
4 workflow_dispatch:
5 pull_request:
6 branches:
7 - main
8 push:
9 tags:
10 - "[0-9]+.[0-9]+.[0-9]+"
11 - "[0-9]+.[0-9]+.[0-9]+.post[0-9]+"
12 release:
13 types:
14 - published
15
16 concurrency:
17 group: cd-${{ github.ref }}
18 cancel-in-progress: true
19
20 permissions: {}
21
22 jobs:
23 dist:
24 name: Build distribution
25 runs-on: ubuntu-latest
26 permissions:
27 contents: read # to checkout
28 steps:
29 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
30 with:
31 persist-credentials: false
32
33 - uses: hynek/build-and-inspect-python-package@d44ca7d91762de7a7d5436ddae667c6da6d1c3df # v2.18.0
34
35 create-release:
36 name: Create GitHub Release
37 needs: [dist]
38 runs-on: ubuntu-latest
39 if: startsWith(github.ref, 'refs/tags/')
40 permissions:
41 contents: write # to create release
42 steps:
43 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
44 with:
45 fetch-depth: 0
46 persist-credentials: false
47
48 - name: Create GitHub Release
49 run: gh release create "$RELEASE_TAG" --generate-notes
50 env:
51 GH_TOKEN: ${{ github.token }}
52 RELEASE_TAG: ${{ github.ref_name }}
53
54 publish:
55 name: Publish to PyPI
56 needs: [dist]
57 runs-on: ubuntu-latest
58 if: startsWith(github.ref, 'refs/tags/') || (github.event_name == 'release' && github.event.action == 'published')
59 environment:
60 name: pypi
61 url: https://pypi.org/p/build
62 permissions:
63 id-token: write # to sign attestation
64 attestations: write # to create attestation
65
66 steps:
67 - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
68 with:
69 name: Packages
70 path: dist
71
72 - name: Generate artifact attestation for sdist and wheel
73 uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
74 with:
75 subject-path: "dist/build-*"
76
77 - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0