Minor CI/CD change #61
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: Test and Deploy | |
on: | |
push: | |
branches: | |
- master | |
create: | |
tags: | |
- 'v*' | |
jobs: | |
test: | |
name: Test | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [ '3.10', '3.11', '3.12' ] | |
os: [ ubuntu-latest ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install poetry | |
run: pipx install poetry | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'poetry' | |
- name: Install dependencies | |
run: poetry install --all-extras | |
- name: Check format | |
run: make check_format | |
- name: Run linters | |
run: make lint | |
- name: Run tests | |
run: make test | |
publish-to-pypi: | |
name: Build and Publish to PyPI | |
needs: | |
- test | |
if: "startsWith(github.ref, 'refs/tags/v')" | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/fast-plate-ocr | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install poetry | |
run: pipx install poetry | |
- name: Setup Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10' | |
- name: Build a binary wheel | |
run: poetry build | |
- name: Publish distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
github-release: | |
name: Create GitHub release | |
needs: | |
- publish-to-pypi | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check package version matches tag | |
id: check-version | |
uses: samuelcolvin/[email protected] | |
with: | |
version_file_path: 'pyproject.toml' | |
- name: Create GitHub Release | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
tag: ${{ github.ref_name }} | |
run: | | |
gh release create "$tag" \ | |
--repo="$GITHUB_REPOSITORY" \ | |
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \ | |
--generate-notes | |
update_docs: | |
name: Update documentation | |
needs: | |
- github-release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install poetry | |
run: pipx install poetry | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'poetry' | |
- name: Configure Git user | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
- name: Retrieve version | |
id: check-version | |
uses: samuelcolvin/[email protected] | |
with: | |
version_file_path: 'pyproject.toml' | |
skip_env_check: true | |
- name: Deploy the docs | |
run: | | |
poetry run mike deploy \ | |
--update-aliases \ | |
--push \ | |
--branch docs-site \ | |
${{ steps.check-version.outputs.VERSION_MAJOR_MINOR }} latest |