From 91247635e77c348f5c909569b42fe3550545d407 Mon Sep 17 00:00:00 2001 From: Raphael Avocegamou Date: Mon, 1 Jun 2026 16:57:37 -0400 Subject: [PATCH] ci: PyPI publish pipeline (Phase 3) Add scripts/publish.sh with --dry-run flag (twine check only) and .github/workflows/publish.yml triggering on v* tags to build and upload the pocketstation package to PyPI via PYPI_API_TOKEN. pyproject.toml already has correct package name, version, and description. --- .github/workflows/publish.yml | 34 ++++++++++++++++++++++++++++++++++ scripts/publish.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 .github/workflows/publish.yml create mode 100755 scripts/publish.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ecf55bd --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,34 @@ +name: publish-pypi + +on: + push: + tags: + - 'v*' + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install build tools + run: pip install build twine + + - name: Build distribution + run: python -m build + + - name: Check distribution + run: python -m twine check dist/* + + - name: Upload to PyPI + run: python -m twine upload dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 0000000..0710398 --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail + +DRY_RUN=false + +for arg in "$@"; do + case "$arg" in + --dry-run) DRY_RUN=true ;; + *) echo "Unknown argument: $arg" >&2; exit 1 ;; + esac +done + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +echo "Building pocketstation distribution..." +python -m build "$REPO_ROOT" + +if [ "$DRY_RUN" = true ]; then + echo "Dry-run: checking distribution with twine..." + python -m twine check "$REPO_ROOT/dist/"* + echo "Dry-run complete. No package was uploaded." +else + echo "Uploading pocketstation to PyPI..." + python -m twine upload "$REPO_ROOT/dist/"* + echo "Uploaded successfully." +fi