Skip to content

Commit b1c2a5e

Browse files
authored
Switch to GitHub trusted publishing (#407)
1 parent 2a9f3f1 commit b1c2a5e

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

.github/workflows/python-publish.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
types: [created]
88

99
jobs:
10-
deploy:
10+
build:
11+
name: Build distribution 📦
1112
runs-on: ubuntu-latest
1213

1314
steps:
@@ -16,14 +17,37 @@ jobs:
1617
uses: actions/setup-python@v5
1718
with:
1819
python-version: "3.x"
19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install setuptools wheel twine
23-
- name: Build and publish
24-
env:
25-
TWINE_USERNAME: __token__
26-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
27-
run: |
28-
python setup.py sdist bdist_wheel
29-
twine upload dist/*
20+
- name: Install pypa/build
21+
run: >-
22+
python3 -m
23+
pip install
24+
build
25+
--user
26+
- name: Build a binary wheel and a source tarball
27+
run: python3 -m build
28+
- name: Store the distribution packages
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: python-package-distributions
32+
path: dist/
33+
34+
deploy:
35+
permissions:
36+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
37+
runs-on: ubuntu-latest
38+
needs:
39+
- build
40+
name: >-
41+
Publish Python 🐍 distribution 📦 to PyPI
42+
environment:
43+
name: pypi
44+
url: https://pypi.org/p/pySwitchbot
45+
46+
steps:
47+
- name: Download all the dists
48+
uses: actions/download-artifact@v4
49+
with:
50+
name: python-package-distributions
51+
path: dist/
52+
- name: Publish package distributions to PyPI
53+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)