-
Notifications
You must be signed in to change notification settings - Fork 15
152 lines (149 loc) · 6.3 KB
/
test_and_publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
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: |
@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 }}