Update README.md #38
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 Publish | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- 'examples/**' | |
- '.github/**' | |
- 'docs/**' | |
- 'scripts/**' | |
- 'Dockerfiles/**' | |
env: | |
DEFAULT_LINUX: "slim" | |
DEFAULT_PYTHON: "3.12" | |
DEFAULT_SCHEMAS: "pydantic" | |
jobs: | |
test: | |
name: Test (${{ matrix.python }}) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] | |
container: | |
image: python:${{ matrix.python }} | |
steps: | |
- uses: actions/checkout@master | |
with: | |
fetch-depth: 0 | |
- name: Commit Linter | |
uses: wagoid/commitlint-github-action@v5 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- id: install | |
name: Install requirements | |
run: | | |
pip install pip poetry --upgrade | |
./scripts/install | |
- id: black | |
name: Code format checking | |
run: ./scripts/black --check . | |
- id: isort | |
name: Imports order checking | |
run: ./scripts/isort --check . | |
- id: ruff | |
name: Code style (ruff) | |
run: ./scripts/ruff . | |
- id: pyright | |
name: Static types check | |
run: ./scripts/pyright | |
- id: tests | |
name: Tests | |
run: ./scripts/test | |
release: | |
needs: test | |
name: Release a new version | |
runs-on: ubuntu-latest | |
outputs: | |
published: ${{ steps.semantic.outputs.new_release_published }} | |
version: ${{ steps.semantic.outputs.new_release_version }} | |
major_version: ${{ steps.semantic.outputs.new_release_major_version }} | |
minor_version: ${{ steps.semantic.outputs.new_release_minor_version }} | |
patch_version: ${{ steps.semantic.outputs.new_release_patch_version }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@master | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Setup poetry | |
run: pip install pip poetry --upgrade | |
- id: semantic | |
name: Semantic Release | |
uses: cycjimmy/semantic-release-action@v3 | |
with: | |
extra_plugins: | | |
[email protected] | |
@semantic-release/changelog | |
@semantic-release/exec | |
@semantic-release/git | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
- name: New release published | |
if: steps.semantic.outputs.new_release_published == 'true' | |
run: | | |
echo "New version: ${{ steps.semantic.outputs.new_release_version }}" | |
docker_push: | |
name: Docker Push (${{ matrix.linux }}, ${{ matrix.python }}, ${{ matrix.schemas }}) | |
needs: release | |
if: ${{ needs.release.outputs.published }} == 'true' | |
environment: | |
name: dockerhub | |
url: https://hub.docker.com/r/vortico/flama | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
linux: ["slim"] | |
python: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
schemas: ["pydantic", "marshmallow", "typesystem"] | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@master | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ secrets.DOCKERHUB_USERNAME }}/flama | |
flavor: | | |
latest=false | |
tags: | | |
type=raw,enable=true,value=${{ matrix.linux }}-${{ needs.release.outputs.major_version }}.${{ needs.release.outputs.minor_version }}-python${{ matrix.python }}-${{ matrix.schemas }} | |
type=raw,enable=true,value=${{ matrix.linux }}-latest-python${{ matrix.python }}-${{ matrix.schemas }} | |
type=raw,enable=${{ matrix.python == env.DEFAULT_PYTHON && 'true' || 'false' }},value=${{ matrix.linux }}-${{ needs.release.outputs.major_version }}.${{ needs.release.outputs.minor_version }}-${{ matrix.schemas }} | |
type=raw,enable=${{ matrix.python == env.DEFAULT_PYTHON && 'true' || 'false' }},value=${{ matrix.linux }}-latest-${{ matrix.schemas }} | |
type=raw,enable=${{ matrix.linux == env.DEFAULT_LINUX && 'true' || 'false' }},value=${{ needs.release.outputs.major_version }}.${{ needs.release.outputs.minor_version }}-python${{ matrix.python }}-${{ matrix.schemas }} | |
type=raw,enable=${{ matrix.linux == env.DEFAULT_LINUX && 'true' || 'false' }},value=latest-python${{ matrix.python }}-${{ matrix.schemas }} | |
type=raw,enable=${{ matrix.schemas == env.DEFAULT_SCHEMAS && 'true' || 'false' }},value=${{ matrix.linux }}-${{ needs.release.outputs.major_version }}.${{ needs.release.outputs.minor_version }}-python${{ matrix.python }} | |
type=raw,enable=${{ matrix.schemas == env.DEFAULT_SCHEMAS && 'true' || 'false' }},value=${{ matrix.linux }}-latest-python${{ matrix.python }} | |
type=raw,enable=${{ matrix.python == env.DEFAULT_PYTHON && (matrix.linux == env.DEFAULT_LINUX && 'true' || 'false') || 'false' }},value=latest-${{ matrix.schemas }} | |
type=raw,enable=${{ matrix.linux == env.DEFAULT_LINUX && (matrix.schemas == env.DEFAULT_SCHEMAS && 'true' || 'false') || 'false' }},value=latest-python${{ matrix.python }} | |
type=raw,enable=${{ matrix.python == env.DEFAULT_PYTHON && (matrix.schemas == env.DEFAULT_SCHEMAS && 'true' || 'false') || 'false' }},value=${{ matrix.linux }}-latest | |
type=raw,enable=${{ matrix.linux == env.DEFAULT_LINUX && (matrix.python == env.DEFAULT_PYTHON && (matrix.schemas == env.DEFAULT_SCHEMAS && 'true' || 'false') || 'false') || 'false' }},value=latest | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
build-args: | | |
PYTHON_VERSION=${{ matrix.python }} | |
SCHEMAS_LIB=${{ matrix.schemas }} | |
context: Dockerfiles/${{ matrix.linux }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |