Skip to content

Commit 0f79b2b

Browse files
authored
Merge pull request #39 from hugovk/deploy-with-trusted-publishing
2 parents 4eeeb28 + 5856c9a commit 0f79b2b

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

.github/workflows/deploy.yml

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

0 commit comments

Comments
 (0)