Skip to content

Commit

Permalink
Publish workflow with build
Browse files Browse the repository at this point in the history
  • Loading branch information
k1o0 committed Jan 16, 2025
1 parent f0f0f3d commit 9bc76fd
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions .github/workflows/python-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,49 @@ permissions:
contents: read

jobs:
deploy:
name: Build and publish Python distributions to PyPI
build:
name: Build Python distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
run: python -m pip install build

- name: Build package
run: python setup.py sdist bdist_wheel
run: python -m build

- name: Publish package
# GitHub recommends pinning 3rd party actions to a commit SHA.
uses: pypa/gh-action-pypi-publish@37f50c210e3d2f9450da2cd423303d6a14a6e29f
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish:
name: >-
Publish Python distributions to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/ONE-api
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
# GitHub recommends pinning 3rd party actions to a commit SHA.
uses: pypa/gh-action-pypi-publish@6f7e8d9c0b1a2c3d4e5f6a7b8c9d0e1f2a3b4c5d
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit 9bc76fd

Please sign in to comment.