|
1 |
| -# This workflow will upload a Python Package using Twine when a release is created |
2 |
| -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries |
3 |
| - |
4 |
| -# This workflow uses actions that are not certified by GitHub. |
5 |
| -# They are provided by a third-party and are governed by |
6 |
| -# separate terms of service, privacy policy, and support |
7 |
| -# documentation. |
8 |
| - |
9 |
| -name: Upload Python Package |
| 1 | +name: Publish Python Package |
10 | 2 |
|
11 | 3 | on:
|
12 | 4 | push:
|
13 | 5 | tags:
|
14 |
| - - '*' |
15 |
| - |
16 |
| -permissions: |
17 |
| - contents: read |
| 6 | + - "**" |
18 | 7 |
|
19 | 8 | jobs:
|
20 |
| - deploy: |
| 9 | + build: |
21 | 10 | runs-on: ubuntu-latest
|
22 |
| - |
| 11 | + outputs: |
| 12 | + version: ${{ steps.inspect_package.outputs.version }} |
23 | 13 | steps:
|
24 |
| - - uses: actions/checkout@v4 |
| 14 | + - uses: actions/checkout@v4 |
25 | 15 |
|
26 |
| - - name: Set up Python 3.10 |
27 |
| - uses: actions/setup-python@v5 |
28 |
| - with: |
29 |
| - python-version: "3.10" |
| 16 | + - name: Install uv |
| 17 | + uses: astral-sh/setup-uv@v2 |
| 18 | + with: |
| 19 | + version: "0.4.12" |
| 20 | + enable-cache: true |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + run: uv python install 3.12 |
| 24 | + |
| 25 | + - name: Build package |
| 26 | + run: uv build |
30 | 27 |
|
31 |
| - - name: Install dependencies |
32 |
| - run: | |
33 |
| - python -m pip install --upgrade pip |
34 |
| - pip install build |
35 |
| - pip install -e '.[docs]' |
| 28 | + - name: Inspect package version |
| 29 | + id: inspect_package |
| 30 | + run: | |
| 31 | + version=$(uvx hatchling version) |
| 32 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
36 | 33 |
|
37 |
| - - name: Build package |
38 |
| - run: python -m build |
| 34 | + - name: Upload package |
| 35 | + uses: actions/upload-artifact@v4 |
| 36 | + with: |
| 37 | + name: package-distributions |
| 38 | + path: dist/ |
39 | 39 |
|
40 |
| - - name: Publish package |
41 |
| - |
| 40 | + pypi-publish: |
| 41 | + runs-on: ubuntu-latest |
| 42 | + needs: build |
| 43 | + |
| 44 | + permissions: |
| 45 | + id-token: write |
| 46 | + |
| 47 | + environment: |
| 48 | + name: pypi |
| 49 | + url: https://pypi.org/project/python-multipart/${{ needs.build.outputs.version }} |
| 50 | + |
| 51 | + steps: |
| 52 | + - name: Download package |
| 53 | + uses: actions/download-artifact@v4 |
42 | 54 | with:
|
43 |
| - user: __token__ |
44 |
| - password: ${{ secrets.PYPI_API_TOKEN }} |
45 |
| - - name: Publish docs |
46 |
| - run: mkdocs gh-deploy --force |
| 55 | + name: package-distributions |
| 56 | + path: dist/ |
| 57 | + |
| 58 | + - name: Publish distribution 📦 to PyPI |
| 59 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments