Publish to TestPyPI #12
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 TestPyPI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Git Tag (Release) to validate and upload' | |
| required: true | |
| type: string | |
| jobs: | |
| validate-release: | |
| name: Validate Release Across Python Versions | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12"] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.tag }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Update pip | |
| run: python -m pip install --upgrade pip | |
| - name: Install wheel | |
| run: python -m pip install --upgrade wheel | |
| - name: Install dependencies | |
| run: | | |
| pip install -r ci/requirements.txt | |
| pip install . | |
| - name: Run tests | |
| run: pytest tests --cov solt --cov-report term-missing -v | |
| - name: Run black | |
| run: black --config=black.toml --check . | |
| - name: Run flake8 | |
| run: flake8 | |
| build-and-publish: | |
| name: Build and Publish to TestPyPI | |
| runs-on: ubuntu-latest | |
| needs: validate-release | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.tag }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install build tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install --upgrade wheel build | |
| - name: Update project name temporarily for TestPyPI | |
| run: | | |
| sed -i "s/name=\"solt\"/name=\"solt-test\"/" setup.py | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Validate built packages with twine | |
| run: | | |
| python -m pip install --upgrade twine | |
| twine check dist/* | |
| - name: Publish to TestPyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| password: ${{ secrets.TEST_PYPI_API }} | |
| packages-dir: dist/ | |
| verbose: true | |