deploy #192
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: deploy | |
on: workflow_dispatch | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Check out GitHub repository ${{ github.repository }} | |
uses: actions/checkout@v4 | |
- name: Set up Python on ${{ runner.os }} | |
uses: actions/setup-python@v5 | |
id: setup_python | |
with: | |
python-version: '3.10' | |
- name: Get Python version | |
run: echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_ENV | |
- name: Cache Poetry dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/pypoetry/cache | |
~/.cache/pypoetry/artifacts | |
key: poetry-${{ runner.os }}-${{ hashFiles('poetry.lock') }} | |
restore-keys: | | |
poetry-${{ runner.os }}- | |
- name: Create virtual environment on ${{ env.PYTHON_VERSION }} | |
run: python -m venv venv | |
- name: Activate virtual environment and install Poetry | |
run: | | |
source venv/bin/activate | |
pip install poetry==1.8.4 | |
- name: Install dependencies with Poetry | |
run: | | |
source venv/bin/activate | |
poetry install --with dev | |
poetry show -l | |
- name: Check and fix with Ruff | |
run: | | |
source venv/bin/activate | |
poetry run ruff check ./tests/*.py ./openseries/*.py --fix --exit-non-zero-on-fix | |
- name: Type check with Mypy | |
run: | | |
source venv/bin/activate | |
poetry run mypy . | |
- name: Tests with Pytest | |
run: | | |
source venv/bin/activate | |
PYTHONPATH=${PWD} poetry run coverage run -m pytest --verbose | |
- name: Report coverage | |
run: | | |
source venv/bin/activate | |
poetry run coverage report | |
- name: Create Git Tag with version from pyproject.toml | |
env: | |
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
run: | | |
export GPG_TTY=$(tty) | |
echo "$GPG_PRIVATE_KEY" | gpg --batch --pinentry-mode loopback --import | |
version=$(grep -oPm1 '(?<=version = ").*(?=")' pyproject.toml) | |
echo "Version: $version" | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR_EMAIL}" | |
git config --global user.signingkey 03BE0D766CA0CF9852B592D5BBE8A9CD2E275A01 | |
git config --global gpg.program gpg | |
git tag -a "$version" -m "Release v$version" | |
git push origin "$version" | |
echo "tag_version=$version" >> "$GITHUB_ENV" | |
- name: Create GitHub release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ env.tag_version }} | |
- name: Build and Publish to Test PyPI | |
run: | | |
source venv/bin/activate | |
poetry config repositories.testpypi https://test.pypi.org/legacy/ | |
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_API_TOKEN }} | |
poetry build | |
poetry check | |
poetry publish --repository testpypi --skip-existing | |
- name: Build and Publish to PyPI | |
run: | | |
source venv/bin/activate | |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} | |
poetry build | |
poetry check | |
poetry publish |