v1.0.53 #4
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: Publish to PyPI | |
| permissions: | |
| contents: read | |
| packages: write | |
| on: | |
| release: | |
| types: [released] | |
| workflow_dispatch: | |
| inputs: | |
| confirm_publish: | |
| description: 'Confirm publishing to PyPI' | |
| required: true | |
| default: 'no' | |
| type: choice | |
| options: | |
| - 'yes' | |
| - 'no' | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Verify version | |
| run: | | |
| VERSION=$(grep '^VERSION' src/amzn_nova_prompt_optimizer/__version__.py | cut -d '"' -f2) | |
| echo "Package version: $VERSION" | |
| # Check if this version already exists on PyPI | |
| if pip index versions nova-prompt-optimizer 2>/dev/null | grep -q "^ *$VERSION$"; then | |
| echo "Error: Version $VERSION already exists on PyPI" | |
| exit 1 | |
| fi | |
| echo "Version check passed: $VERSION is not on PyPI yet" | |
| - name: Build package | |
| run: python -m build | |
| - name: Check package | |
| run: twine check dist/* | |
| - name: Publish to PyPI | |
| if: github.event_name == 'release' || github.event.inputs.confirm_publish == 'yes' | |
| env: | |
| TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: twine upload dist/* |