|
1 |
| -name: Create library release archives, create a GH release and publish PyPI wheel and sdist on tag in main branch |
2 |
| - |
3 |
| - |
4 |
| -# This is executed automatically on a tag in the main branch |
5 |
| - |
6 |
| -# Summary of the steps: |
7 |
| -# - build wheels and sdist |
8 |
| -# - upload wheels and sdist to PyPI |
9 |
| -# - create gh-release and upload wheels and dists there |
10 |
| -# TODO: smoke test wheels and sdist |
11 |
| -# TODO: add changelog to release text body |
12 |
| - |
13 |
| -# WARNING: this is designed only for packages building as pure Python wheels |
| 1 | +name: Build and Publish |
14 | 2 |
|
15 | 3 | on:
|
16 | 4 | workflow_dispatch:
|
| 5 | + pull_request: |
17 | 6 | push:
|
18 | 7 | tags:
|
19 |
| - - "v*.*.*" |
| 8 | + - "v*" |
20 | 9 |
|
21 | 10 | jobs:
|
22 |
| - build-pypi-distribs: |
23 |
| - name: Build and publish library to PyPI |
24 |
| - runs-on: ubuntu-20.04 |
| 11 | + build_and_upload: |
| 12 | + name: Build and Upload Archive |
| 13 | + runs-on: ubuntu-24.04 |
25 | 14 |
|
26 | 15 | steps:
|
27 | 16 | - uses: actions/checkout@v4
|
28 |
| - - name: Set up Python |
29 |
| - uses: actions/setup-python@v4 |
30 |
| - with: |
31 |
| - python-version: 3.9 |
32 |
| - |
33 |
| - - name: Install pypa/build |
34 |
| - run: python -m pip install build --user |
35 | 17 |
|
36 |
| - - name: Build a binary wheel and a source tarball |
37 |
| - run: python -m build --sdist --wheel --outdir dist/ |
38 |
| - |
39 |
| - - name: Upload built archives |
40 |
| - uses: actions/upload-artifact@v4 |
| 18 | + - name: Install uv |
| 19 | + uses: astral-sh/setup-uv@22695119d769bdb6f7032ad67b9bca0ef8c4a174 # v5.4.0 |
| 20 | + with: |
| 21 | + enable-cache: true |
| 22 | + pyproject-file: "pyproject.toml" |
| 23 | + |
| 24 | + - name: Build 📦 package |
| 25 | + run: | |
| 26 | + uv sync |
| 27 | + uv build |
| 28 | + shell: bash |
| 29 | + |
| 30 | + - name: Upload artifacts |
| 31 | + if: github.event_name == 'push' |
| 32 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # 4.6.2 |
41 | 33 | with:
|
42 | 34 | name: pypi_archives
|
43 |
| - path: dist/* |
44 |
| - |
| 35 | + path: dist/python_inspector-*-py3-none-any.whl |
| 36 | + overwrite: true |
45 | 37 |
|
46 | 38 | create-gh-release:
|
47 | 39 | name: Create GH release
|
48 |
| - needs: |
49 |
| - - build-pypi-distribs |
50 |
| - runs-on: ubuntu-20.04 |
| 40 | + runs-on: ubuntu-24.04 |
| 41 | + needs: build_and_upload |
51 | 42 |
|
52 | 43 | steps:
|
53 | 44 | - name: Download built archives
|
54 |
| - uses: actions/download-artifact@v4 |
| 45 | + if: github.event_name == 'push' |
| 46 | + uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # 4.2.1 |
55 | 47 | with:
|
56 | 48 | name: pypi_archives
|
57 | 49 | path: dist
|
58 | 50 |
|
59 | 51 | - name: Create GH release
|
60 |
| - uses: softprops/action-gh-release@v1 |
| 52 | + if: github.event_name == 'push' |
| 53 | + uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # 2.2.1 |
61 | 54 | with:
|
62 | 55 | draft: true
|
63 | 56 | files: dist/*
|
64 | 57 |
|
65 |
| - |
66 | 58 | create-pypi-release:
|
67 | 59 | name: Create PyPI release
|
68 |
| - needs: |
69 |
| - - create-gh-release |
70 |
| - runs-on: ubuntu-20.04 |
71 |
| - |
| 60 | + needs: create-gh-release |
| 61 | + runs-on: ubuntu-24.04 |
72 | 62 | steps:
|
73 |
| - - name: Download built archives |
74 |
| - uses: actions/download-artifact@v4 |
75 |
| - with: |
76 |
| - name: pypi_archives |
77 |
| - path: dist |
78 |
| - |
79 |
| - - name: Publish to PyPI |
80 |
| - if: startsWith(github.ref, 'refs/tags') |
81 |
| - uses: pypa/gh-action-pypi-publish@release/v1 |
| 63 | + - name: Install uv |
| 64 | + if: github.event_name == 'push' |
| 65 | + uses: astral-sh/setup-uv@22695119d769bdb6f7032ad67b9bca0ef8c4a174 # v5.4.0 |
82 | 66 | with:
|
83 |
| - password: ${{ secrets.PYPI_API_TOKEN }} |
| 67 | + enable-cache: true |
| 68 | + pyproject-file: "pyproject.toml" |
| 69 | + |
| 70 | + - name: Publish |
| 71 | + if: github.event_name == 'push' |
| 72 | + env: |
| 73 | + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 74 | + run: | |
| 75 | + uv publish dist/* |
0 commit comments