Publish Code #1
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
| # | |
| # Publish releases to PyPi | |
| # | |
| name: Publish Code | |
| on: | |
| workflow_call: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| publish: | |
| name: Publish ${{ matrix.variant }} release to PyPi | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 1 | |
| matrix: | |
| variant: [ full, lite ] | |
| env: | |
| PYTHON_VERSION: "3.13" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python ${{ env.PYTHON_VERSION }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Cache dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-build-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build- | |
| - name: Install dependencies | |
| run: | | |
| if [ "${{ matrix.variant }}" = "lite" ]; then | |
| python -m pip install toml | |
| fi | |
| python -m pip install -e '.[build]' | |
| - name: Generate lite TOML | |
| if: matrix.variant == 'lite' | |
| run: | | |
| python scripts/generate_lite_toml.py | |
| cp pyproject-lite.toml pyproject.toml | |
| - name: Build | |
| run: | | |
| rm -fr ./dist | |
| python -m build | |
| - name: Check | |
| run: twine check --strict ./dist/* | |
| - name: Test Upload | |
| env: | |
| TWINE_NON_INTERACTIVE: "1" | |
| TWINE_USERNAME: ${{ secrets.PYPI_TEST_USERNAME }} | |
| TWINE_PASSWORD: ${{ matrix.variant == 'lite' && secrets.PYPI_TEST_PASSWORD_LITE || secrets.PYPI_TEST_PASSWORD }} | |
| run: twine upload --disable-progress-bar --repository testpypi --skip-existing ./dist/* | |
| - name: Upload | |
| if: startsWith(github.ref, 'refs/tags/') | |
| env: | |
| TWINE_NON_INTERACTIVE: "1" | |
| TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
| TWINE_PASSWORD: ${{ matrix.variant == 'lite' && secrets.PYPI_PASSWORD_LITE || secrets.PYPI_PASSWORD }} | |
| run: twine upload --disable-progress-bar --skip-existing ./dist/* |