Repository navigation
v1.2.1 #7
Workflow file for this run
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: Release to PyPI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| test_pypi: | |
| description: 'Upload to Test PyPI instead of PyPI' | |
| required: false | |
| default: false | |
| type: boolean | |
| release: | |
| types: [published] | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| environment: release | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.13' | |
| - name: Check version matches release tag | |
| if: github.event_name == 'release' | |
| run: | | |
| # Extract version from pyproject.toml using regex (no imports needed) | |
| PACKAGE_VERSION=$(grep -oP '^version\s*=\s*"\K[^"]+' pyproject.toml) | |
| # Extract tag name (remove 'v' prefix if present) | |
| TAG_NAME="${{ github.event.release.tag_name }}" | |
| TAG_VERSION="${TAG_NAME#v}" | |
| echo "Package version: $PACKAGE_VERSION" | |
| echo "Release tag: $TAG_NAME" | |
| echo "Tag version (normalized): $TAG_VERSION" | |
| if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then | |
| echo "ERROR: Version mismatch!" | |
| echo "Package version ($PACKAGE_VERSION) does not match release tag ($TAG_VERSION)" | |
| echo "Please update version in pyproject.toml to match the release tag" | |
| exit 1 | |
| fi | |
| echo "Version check passed: $PACKAGE_VERSION matches $TAG_VERSION" | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| - name: Install build dependencies | |
| run: | | |
| uv pip install --python ${Python_ROOT_DIR} build twine | |
| - name: Build package | |
| run: python -m build | |
| - name: Check package | |
| run: python -m twine check dist/* | |
| - name: Upload to Test PyPI | |
| if: ${{ github.event.inputs.test_pypi == 'true' }} | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
| repository-url: https://test.pypi.org/legacy/ | |
| verbose: true | |
| - name: Upload to PyPI | |
| if: ${{ github.event.inputs.test_pypi != 'true' }} | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| verbose: true | |
| smoke-test: | |
| runs-on: ubuntu-latest | |
| needs: build-and-publish | |
| steps: | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.13' | |
| - name: Install uv and pipx | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| uv pip install --python ${Python_ROOT_DIR} pipx | |
| - name: Wait for package availability | |
| run: | | |
| echo "Waiting for package to be available on PyPI..." | |
| sleep 60 | |
| - name: Test pipx run programbench --help (Test PyPI) | |
| if: ${{ github.event.inputs.test_pypi == 'true' }} | |
| run: pipx run --pip-args="--index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/" programbench --help | |
| - name: Test pipx run programbench --help (PyPI) | |
| if: ${{ github.event.inputs.test_pypi != 'true' }} | |
| run: pipx run programbench --help | |
| - name: Test uvx programbench --help (Test PyPI) | |
| if: ${{ github.event.inputs.test_pypi == 'true' }} | |
| run: uvx --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ programbench --help | |
| - name: Test uvx programbench --help (PyPI) | |
| if: ${{ github.event.inputs.test_pypi != 'true' }} | |
| run: uvx programbench --help | |
| - name: Test pip install and CLI (Test PyPI) | |
| if: ${{ github.event.inputs.test_pypi == 'true' }} | |
| run: | | |
| uv pip install --python ${Python_ROOT_DIR} --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ programbench | |
| programbench --help | |
| - name: Test pip install and CLI (PyPI) | |
| if: ${{ github.event.inputs.test_pypi != 'true' }} | |
| run: | | |
| uv pip install --python ${Python_ROOT_DIR} programbench | |
| programbench --help |