Skip to content

Commit 598ad99

Browse files
committed
Switch to trusted publishing for releases
1 parent ec71fbe commit 598ad99

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

.github/workflows/python-publish.yml

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,47 @@ on:
77
types: [created]
88

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

1314
steps:
14-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1516
- name: Set up Python
16-
uses: actions/setup-python@v2
17+
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 --verbose 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)