Update main.yml #33
Workflow file for this run
This file contains 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: Build and Release | |
on: | |
push: | |
branches: | |
- '**' # Run on all branches for push | |
jobs: | |
run-unit-tests: | |
strategy: | |
matrix: | |
python-version: ['3.9', '3.10', '3.11', '3.12'] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install system-level Python packages | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y python3-distutils python3-setuptools python3-wheel | |
- name: Install Poetry | |
uses: abatilo/actions-poetry@v4 | |
- name: Install dependencies | |
run: | | |
poetry install --no-interaction --no-ansi --no-root | |
- uses: actions/cache@v3 | |
name: Define a cache for the virtual environment based on the dependencies lock file | |
with: | |
path: ./.venv | |
key: venv-${{ hashFiles('poetry.lock') }} | |
- name: Run Unit Tests | |
run: | | |
mkdir test-results | |
poetry run python -m pytest --junitxml=test-results/junit.xml -v tests | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results | |
path: test-results | |
verify: | |
if: github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Verify | |
run: | | |
./verify.sh | |
publish-to-test-pypi: | |
if: github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install Poetry | |
uses: abatilo/actions-poetry@v4 | |
- name: Install dependencies | |
run: | | |
poetry install --no-interaction --no-ansi --no-root | |
- name: Build package | |
run: | | |
poetry build | |
- name: Publish to Test PyPI | |
env: | |
PYPI_TEST_TOKEN: ${{ secrets.PYPI_TEST_TOKEN }} | |
run: | | |
poetry config repositories.testpypi https://test.pypi.org/legacy/ | |
poetry publish -u __token__ -p $PYPI_TEST_TOKEN -r testpypi | |
publish-to-pypi: | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install Poetry | |
uses: abatilo/actions-poetry@v4 | |
- name: Install dependencies | |
run: | | |
poetry install --no-interaction --no-ansi --no-root | |
- name: Build package | |
run: | | |
poetry build | |
- name: Publish to PyPI | |
env: | |
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
poetry publish -u __token__ -p $PYPI_TOKEN |