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