Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish to PyPI

on:
release:
types: [published]
workflow_dispatch:
inputs:
environment:
description: 'Target environment'
required: true
type: choice
options:
- pypi
- testpypi
default: 'testpypi'

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

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

- name: Build package
run: python -m build

- name: Check build artifacts exist
run: |
ls -la dist/
test -f dist/*.whl || exit 1
test -f dist/*.tar.gz || exit 1
Comment on lines +42 to +43
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using shell globbing with test -f may fail if multiple files match the pattern. Use ls dist/*.whl | wc -l or find commands to ensure at least one file exists of each type."

Suggested change
test -f dist/*.whl || exit 1
test -f dist/*.tar.gz || exit 1
find dist -maxdepth 1 -name '*.whl' -type f | grep -q . || exit 1
find dist -maxdepth 1 -name '*.tar.gz' -type f | grep -q . || exit 1

Copilot uses AI. Check for mistakes.

- name: Publish to Production PyPI
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.environment == 'pypi')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Publish to Test PyPI
if: github.event_name == 'workflow_dispatch' && inputs.environment == 'testpypi'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
Loading