Github Actions: Publish tagged commits into PyPI #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish xrpl-py 🐍 distribution 📦 to PyPI | |
env: | |
POETRY_VERSION: 1.8.3 | |
on: push | |
jobs: | |
build: | |
name: Build distribution 📦 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Load cached .local | |
id: cache-poetry | |
uses: actions/cache@v3 | |
with: | |
path: /home/runner/.local | |
key: dotlocal-${{ env.POETRY_VERSION }} | |
- name: Install poetry | |
if: steps.cache-poetry.outputs.cache-hit != 'true' | |
run: | | |
curl -sSL https://install.python-poetry.org/ | python - --version ${{ env.POETRY_VERSION }} | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Build a binary wheel and a source tarball | |
run: poetry build | |
- name: Store the distribution packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
publish-to-pypi: | |
name: >- | |
Publish Python 🐍 distribution 📦 to PyPI | |
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | |
runs-on: ubuntu-latest | |
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 | |
uses: pypa/gh-action-pypi-publish@release/v1 |