Skip to content

Test and Publish Pre-Release Version of Python Package #11

Test and Publish Pre-Release Version of Python Package

Test and Publish Pre-Release Version of Python Package #11

# Runs a build test every time a commit is pushed to branch 'main'.
name: Test and Publish Pre-Release Version of Python Package
on:
push:
tags:
- 'pre*'
jobs:
test-ddm:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
db: [mysql] # postgres, sqlite
python-version: [3.8, 3.11]
include:
- db: mysql
db_port: 3306
db_engine: django.db.backends.mysql
db_user: root
services:
mysql:
image: mysql
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: ddmtestdb
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install psycopg2 mysqlclient
pip install -r test_project/dev_requirements.txt
- name: Run Tests With ${{ matrix.db }}
env:
DB: ${{ matrix.db }}
DB_ENGINE: ${{ matrix.db_engine }}
DB_NAME: ddmtestdb
DB_USER: ${{ matrix.db_user }}
DB_PASSWORD: password
DB_PORT: ${{ matrix.db_port }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: |
python test_project/manage.py test ddm
publish-docs:
needs: test-ddm
if: success()
uses: ./.github/workflows/publish-docs.yml
deploy:
needs: test-ddm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Extract version name
run: echo "PKG_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: Update package version in files
run: |
sed -i "s/__version__/${PKG_VERSION#pre}/g" setup.cfg
sed -i "s/__version__/${PKG_VERSION#pre}/g" ddm/__init__.py
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}