1717 - ' .github/workflows/ci.yml'
1818 pull_request :
1919env :
20- LATEST_PY_VERSION : ' 3.12 '
20+ LATEST_PY_VERSION : ' 3.13 '
2121
2222jobs :
2323 tests :
2424 runs-on : ubuntu-latest
2525 strategy :
2626 matrix :
27- python-version : ['3.8 ', '3.9 ', '3.10 ', '3.11 ', '3.12 ']
27+ python-version : ['3.9 ', '3.10 ', '3.11 ', '3.12 ', '3.13 ']
2828
2929 steps :
3030 - uses : actions/checkout@v4
@@ -134,12 +134,6 @@ jobs:
134134 needs : [tests]
135135 if : github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
136136 runs-on : ubuntu-latest
137- strategy :
138- matrix :
139- image-version :
140- - ' uvicorn'
141- - ' gunicorn'
142-
143137 steps :
144138 - name : Checkout
145139 uses : actions/checkout@v4
@@ -157,40 +151,26 @@ jobs:
157151 username : ${{ github.actor }}
158152 password : ${{ secrets.GITHUB_TOKEN }}
159153
160- - name : Set tag version
161- id : tag
162- run : |
163- echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
164-
165- - name : Image name
166- id : image
167- run : |
168- if [ ${{ matrix.image-version }} = 'uvicorn' ]; then
169- echo "name=${{ github.repository }}:uvicorn-" >> $GITHUB_OUTPUT
170- else
171- echo "name=${{ github.repository }}:" >> $GITHUB_OUTPUT
172- fi
173-
174- # Push `latest` when commiting to main
175- - name : Build and push
176- if : github.ref == 'refs/heads/main'
177- uses : docker/build-push-action@v6
154+ - name : Docker meta
155+ id : meta
156+ uses : docker/metadata-action@v5
178157 with :
179- platforms : linux/amd64,linux/arm64
180- context : .
181- file : dockerfiles/Dockerfile.${{ matrix.image-version }}
182- push : true
158+ images : |
159+ ghcr.io/${{ github.repository }}
160+ flavor : |
161+ latest=false
183162 tags : |
184- ghcr.io/${{ steps.image.outputs.name }}latest
163+ type=semver,pattern={{version}}
164+ type=raw,value=latest,enable={{is_default_branch}}
185165
186- # Push `{VERSION}` when pushing a new tag
187166 - name : Build and push
188- if : startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
189167 uses : docker/build-push-action@v6
190168 with :
191169 platforms : linux/amd64,linux/arm64
192170 context : .
193- file : dockerfiles/Dockerfile.${{ matrix.image-version }}
194- push : true
195- tags : |
196- ghcr.io/${{ steps.image.outputs.name }}${{ steps.tag.outputs.version }}
171+ file : dockerfiles/Dockerfile
172+ push : ${{ github.event_name != 'pull_request' }}
173+ tags : ${{ steps.meta.outputs.tags }}
174+ labels : ${{ steps.meta.outputs.labels }}
175+ cache-from : type=gha
176+ cache-to : type=gha,mode=max
0 commit comments