Skip to content

Commit

Permalink
Switch to trusted publishing for releases (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Nov 18, 2024
1 parent ec71fbe commit d8de234
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,47 @@ on:
types: [created]

jobs:
deploy:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload --verbose dist/*
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

deploy:
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
runs-on: ubuntu-latest
needs:
- build
name: >-
Publish Python 🐍 distribution 📦 to PyPI
environment:
name: pypi
url: https://pypi.org/p/pySwitchbot

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

0 comments on commit d8de234

Please sign in to comment.