Skip to content

Publish to TestPyPI #18

Publish to TestPyPI

Publish to TestPyPI #18

Workflow file for this run

name: Publish to TestPyPI
on:
workflow_dispatch:
inputs:
tag:
description: 'Git Tag (Release) to validate and upload'
required: true
type: string
jobs:
test-all:
name: Run Tests and Linting
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
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 and build tools
run: python -m pip install --upgrade wheel build
- name: Install PyTorch and dependencies
run: |
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -r ci/requirements.txt
pip install . --no-deps
- name: Run tests
run: pytest tests --cov solt --cov-report=xml --junitxml=./junit.xml
- name: Check code formatting
run: black --config=black.toml --check .
- name: Run flake8 linter
run: flake8
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
build-and-publish:
name: Build and Publish to TestPyPI
runs-on: ubuntu-latest
needs: test-all
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: Set name and version for TestPyPI
run: |
VERSION="${{ github.event.inputs.tag || github.event.release.tag_name }}"
VERSION="${VERSION#v}"
sed -i "s/name=\"solt\"/name=\"solt-test\"/" setup.py
sed -i "s/version=\"[^\"]*\"/version=\"$VERSION\"/" 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