Skip to content

Commit 946ac53

Browse files
authored
Add a deploy.yml that supports trusted publishing.
1 parent 529a4eb commit 946ac53

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
release:
8+
types:
9+
- published
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
# Always build & lint package.
17+
build-package:
18+
name: Build & verify package
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- uses: hynek/build-and-inspect-python-package@v1
27+
28+
# Upload to Test PyPI on every commit on main.
29+
release-test-pypi:
30+
name: Publish in-dev package to test.pypi.org
31+
if: |
32+
github.repository_owner == 'sphinx-contrib'
33+
&& github.event_name == 'push'
34+
&& github.ref == 'refs/heads/main'
35+
runs-on: ubuntu-latest
36+
needs: build-package
37+
38+
permissions:
39+
id-token: write
40+
41+
steps:
42+
- name: Download packages built by build-and-inspect-python-package
43+
uses: actions/download-artifact@v3
44+
with:
45+
name: Packages
46+
path: dist
47+
48+
- name: Upload package to Test PyPI
49+
uses: pypa/gh-action-pypi-publish@release/v1
50+
with:
51+
repository-url: https://test.pypi.org/legacy/
52+
53+
# Upload to real PyPI on GitHub Releases.
54+
release-pypi:
55+
name: Publish released package to pypi.org
56+
if: |
57+
github.repository_owner == 'sphinx-contrib'
58+
&& github.event.action == 'published'
59+
runs-on: ubuntu-latest
60+
needs: build-package
61+
62+
permissions:
63+
id-token: write
64+
65+
steps:
66+
- name: Download packages built by build-and-inspect-python-package
67+
uses: actions/download-artifact@v3
68+
with:
69+
name: Packages
70+
path: dist
71+
72+
- name: Upload package to PyPI
73+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)