Publish π π¦ to TestPyPI #5
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 π π¦ to TestPyPI | |
on: | |
workflow_dispatch: | |
jobs: | |
publish-to-testpypi: | |
if: github.event_name == 'workflow_dispatch' # Only allow manual triggers | |
name: Publish π distribution π¦ to TestPyPI | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.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: Install dependencies | |
run: | | |
uv sync | |
- name: Get version from __init__.py | |
id: get_version | |
run: | | |
version=$(uv run python -c "from src.parllama import __version__; print(__version__)") | |
echo "Raw version output: $version" | |
echo "VERSION=$version" >> $GITHUB_ENV | |
- name: Check version | |
id: check_version | |
run: | | |
echo "Version in env: ${{ env.VERSION }}" | |
if [ -z "${{ env.VERSION }}" ]; then | |
echo "Error: VERSION is empty" | |
exit 1 | |
fi | |
- name: Restore cached build artifacts | |
uses: actions/cache@v4 | |
with: | |
path: dist | |
key: ${{ runner.os }}-3.11-x64-${{ hashFiles('**/pyproject.toml') }}-${{ github.sha }} | |
fail-on-cache-miss: true | |
- name: Publish distribution π¦ to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
skip-existing: true | |
- 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 TestPyPI.' | |
continue-on-error: true |