Skip to content

Commit ea9865d

Browse files
authored
Merge pull request #64 from Preocts/trusted-publishing
Create trusted publishing workflow for pypi
2 parents 7174229 + fe15b9f commit ea9865d

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/pypi-publish.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Publish Python distribution to PyPI"
2+
# Uses:
3+
# https://github.com/actions/setup-python : 0b93645e9fea7318ecaed2b359559ac225c90a2b
4+
# https://github.com/actions/checkout : 11bd71901bbe5b1630ceea73d27597364c9af683
5+
# https://github.com/actions/download-artifact : fa0a91b85d4f404e444e00e005971372dc801d1c6
6+
# https://github.com/actions/upload-artifact : 6f51ac03b9356f520e9adb1b1b7802705f340c2b
7+
# https://github.com/actions/pypa/gh-action-pypi-publish : 76f52bc884231f62b9a034ebfe128415bbaabdfc
8+
9+
on:
10+
release:
11+
types: [published]
12+
13+
jobs:
14+
build:
15+
name: "Build distribution"
16+
runs-on: "ubuntu-latest"
17+
18+
steps:
19+
- uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
20+
with:
21+
persist-credentials: false
22+
23+
- name: "Set up Python"
24+
uses: "actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b"
25+
with:
26+
python-version: "3.12"
27+
28+
- name: "Build the package"
29+
run: "python -m pip install nox; nox --session build"
30+
31+
- name: "Store the distribution packages"
32+
uses: "actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b"
33+
with:
34+
name: "python-package-distributions"
35+
path: "dist/"
36+
37+
publish-to-pypi:
38+
name: "Publish Python Distribution to PyPI"
39+
if: startsWith(github.ref, 'refs/tags/')
40+
needs: ["build"]
41+
runs-on: "ubuntu-latest"
42+
environment:
43+
name: "pypi"
44+
url: "https://pypi.org/p/commented-configparser"
45+
permissions:
46+
id-token: "write"
47+
48+
steps:
49+
- name: "Download all the dists"
50+
uses: "actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d1c6"
51+
with:
52+
name: "python-package-distributions"
53+
path: "dist/"
54+
55+
- name: "Publish distribution to PyPI"
56+
uses: "pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc"

0 commit comments

Comments
 (0)