Debian Codegraph @

.github/workflows/pypi-package.yml

raw
1 name: Build and maybe upload PyPI package
2
3 on:
4 push:
5 branches: [main]
6 tags: ["*"]
7 pull_request:
8 branches: [main]
9 release:
10 types: [published]
11 workflow_dispatch:
12
13 env:
14 FORCE_COLOR: "1" # Make tools pretty.
15
16 permissions:
17 contents: read
18
19 jobs:
20 # Always build and lint
21 build-package:
22 name: Build package 📦
23 runs-on: ubuntu-latest
24
25 steps:
26 - name: "Checkout repository 🛎"
27 uses: actions/checkout@v4
28 with:
29 fetch-depth: 0
30
31 - name: "Build and inspect package 🛠"
32 uses: hynek/build-and-inspect-python-package@v2
33
34 # Upload to Test PyPI on every commit on main.
35 release-test-pypi:
36 name: Publish in-dev package to test.pypi.org
37 environment: release-test-pypi
38 permissions:
39 id-token: write
40 if: github.event_name == 'push' && github.ref == 'refs/heads/main'
41 runs-on: ubuntu-latest
42 needs: build-package
43
44 steps:
45 - name: "Download package built in previous job 📥"
46 uses: actions/download-artifact@v4
47 with:
48 name: Packages
49 path: dist
50 - name: "Upload package to Test PyPI 🚀"
51 uses: pypa/gh-action-pypi-publish@release/v1
52 with:
53 repository-url: https://test.pypi.org/legacy/
54
55 # Upload to real PyPI on GitHub Releases.
56 release-pypi:
57 name: Publish released package to pypi.org 🚀
58 environment:
59 name: release-pypi
60 url: https://pypi.org/project/accessible-pygments/
61 permissions:
62 id-token: write
63 if: github.repository_owner == 'Quansight-Labs' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')
64 runs-on: ubuntu-latest
65 needs: build-package
66
67 steps:
68 - name: "Download packages built in previous job 📥"
69 uses: actions/download-artifact@v4
70 with:
71 name: Packages
72 path: dist
73
74 - name: "Upload package to PyPI 🚀"
75 uses: pypa/gh-action-pypi-publish@release/v1
76 with:
77 print-hash: true
78 verbose: true