Skip to content

Publish 🐍 πŸ“¦ to PyPI #66

Publish 🐍 πŸ“¦ to PyPI

Publish 🐍 πŸ“¦ to PyPI #66

Workflow file for this run

name: Publish 🐍 πŸ“¦ to PyPI
on:
workflow_dispatch:
release:
types: [ published ]
jobs:
publish-to-pypi:
if: github.event_name == 'workflow_dispatch' # Only allow manual triggers
name: Publish 🐍 distribution πŸ“¦ to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/parllama
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Get version from __init__.py
id: get_version
run: |
echo "VERSION=$(uv run python -c "from src.parllama import __version__; print(__version__)")" >> $GITHUB_ENV
echo "Version extracted: ${{ env.VERSION }}"
- name: Restore cached build artifacts
uses: actions/cache@v4
with:
path: dist
key: ${{ runner.os }}-3.11-${{ runner.architecture }}-${{ hashFiles('**/pyproject.toml') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-3.11-${{ runner.architecture }}-${{ hashFiles('**/pyproject.toml') }}-
${{ runner.os }}-3.11-${{ runner.architecture }}-${{ env.VERSION }}-
${{ runner.os }}-3.11-${{ runner.architecture }}-
fail-on-cache-miss: true
- name: Publish distribution πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: 'The project {{ EVENT_PAYLOAD.repository.full_name }} ${{ env.VERSION }} has been published to PyPI.'
continue-on-error: true