✨ Docs page using Scalar (#179) #59
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.13" | |
DEFAULT_SCHEMAS: "pydantic" | |
jobs: | |
test: | |
name: Test (${{ matrix.python }}) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
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: 22 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
python-version: ${{ matrix.python }} | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- id: install | |
name: Install project | |
run: ./scripts/install | |
- id: format | |
name: Code format checking | |
run: ./scripts/format --check . | |
- id: lint | |
name: Code linting | |
run: ./scripts/lint --output-format=github . | |
- id: typecheck | |
name: Static types check | |
run: ./scripts/typecheck | |
- id: tests | |
name: Tests | |
run: ./scripts/test | |
release: | |
needs: test | |
name: Release a new version | |
runs-on: ubuntu-latest | |
environment: pypi | |
permissions: | |
packages: write | |
pull-requests: write | |
contents: write | |
issues: write | |
id-token: write | |
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: 22 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON }} | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- id: semantic | |
name: Semantic Release | |
uses: cycjimmy/semantic-release-action@v4 | |
with: | |
extra_plugins: | | |
[email protected] | |
@semantic-release/changelog | |
@semantic-release/exec | |
@semantic-release/git | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_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.9", "3.10", "3.11", "3.12", "3.13"] | |
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 }} |