Manual Publish to PyPI #7
This file contains hidden or 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: Manual Publish to PyPI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (without v prefix, e.g. 1.2.5)' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: read | |
| jobs: | |
| manual-publish: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| steps: | |
| - 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@v3 | |
| with: | |
| enable-cache: true | |
| - name: Verify version matches | |
| run: | | |
| VERSION=$(grep -m 1 "^version = " pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| echo "Version in pyproject.toml: $VERSION" | |
| echo "Version requested: ${{ github.event.inputs.version }}" | |
| if [ "$VERSION" != "${{ github.event.inputs.version }}" ]; then | |
| echo "::error::Version mismatch! pyproject.toml has $VERSION but requested ${{ github.event.inputs.version }}" | |
| exit 1 | |
| fi | |
| - name: Install dependencies | |
| run: uv sync --all-extras --dev | |
| - name: Build package (uv) | |
| run: uv build | |
| - name: Verify distribution files | |
| run: | | |
| echo "Generated distribution files:" | |
| ls -la dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_TOKEN }} | |
| packages-dir: dist/ | |
| verbose: true | |
| - name: Verify publication | |
| run: | | |
| echo "Waiting for PyPI to index the package..." | |
| sleep 30 | |
| # Use uv to verify the version is available | |
| uv pip install commitloom==${{ github.event.inputs.version }} --no-deps | |
| INSTALLED_VERSION=$(uv run python -c "import commitloom; print(commitloom.__version__)") | |
| echo "Installed version: $INSTALLED_VERSION" | |
| if [ "$INSTALLED_VERSION" == "${{ github.event.inputs.version }}" ]; then | |
| echo "✅ Publication successful!" | |
| else | |
| echo "⚠️ Publication may have failed or not indexed yet" | |
| fi |