Publish to PyPI #73
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 | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Release tag (e.g. v1.2.3 or reflex-lucide-v0.1.0)" | |
| required: true | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.release.tag_name || inputs.tag }} | |
| fetch-tags: true | |
| fetch-depth: 0 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Parse release tag | |
| id: parse | |
| run: | | |
| TAG="${{ github.event.release.tag_name || inputs.tag }}" | |
| # Tag format: v1.2.3 for reflex, reflex-lucide-v0.1.0 for sub-packages | |
| if [[ "$TAG" =~ ^v([0-9].*)$ ]]; then | |
| echo "package=reflex" >> "$GITHUB_OUTPUT" | |
| echo "build_dir=." >> "$GITHUB_OUTPUT" | |
| elif [[ "$TAG" =~ ^(.+)-v([0-9].*)$ ]]; then | |
| PACKAGE="${BASH_REMATCH[1]}" | |
| if [ ! -d "packages/$PACKAGE" ]; then | |
| echo "Error: packages/$PACKAGE does not exist" | |
| exit 1 | |
| fi | |
| echo "package=$PACKAGE" >> "$GITHUB_OUTPUT" | |
| echo "build_dir=packages/$PACKAGE" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Error: Tag '$TAG' does not match expected format (v* or <package>-v*)" | |
| exit 1 | |
| fi | |
| - name: Build | |
| run: uv build --directory "${{ steps.parse.outputs.build_dir }}" | |
| - name: Verify .pyi files in wheel | |
| if: steps.parse.outputs.package == 'reflex' | |
| run: | | |
| if unzip -l ${{ steps.parse.outputs.build_dir }}/dist/*.whl | grep '\.pyi$'; then | |
| echo "โ .pyi files found in distribution" | |
| else | |
| echo "Error: No .pyi files found in wheel" | |
| exit 1 | |
| fi | |
| - name: Publish | |
| run: uv publish dist/* |