|
17 | 17 | strategy: |
18 | 18 | fail-fast: false |
19 | 19 | matrix: |
20 | | - python-version: ["3.10", "3.11", "3.12"] |
| 20 | + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] |
21 | 21 |
|
22 | 22 | steps: |
23 | 23 | - uses: actions/checkout@v4 |
|
41 | 41 | run: python ./test/unit_test/start_automation/extend_automation_test.py |
42 | 42 | env: |
43 | 43 | PYTHONPATH: . |
| 44 | + |
| 45 | + publish: |
| 46 | + needs: unit-tests |
| 47 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 48 | + runs-on: ubuntu-latest |
| 49 | + permissions: |
| 50 | + contents: write |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + with: |
| 54 | + fetch-depth: 0 |
| 55 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + - name: Set up Python |
| 57 | + uses: actions/setup-python@v5 |
| 58 | + with: |
| 59 | + python-version: "3.12" |
| 60 | + - name: Bump patch version |
| 61 | + id: bump |
| 62 | + run: | |
| 63 | + python - <<'PY' |
| 64 | + import os |
| 65 | + import pathlib |
| 66 | + import re |
| 67 | +
|
| 68 | + path = pathlib.Path("pyproject.toml") |
| 69 | + text = path.read_text(encoding="utf-8") |
| 70 | + match = re.search(r'^version = "(\d+)\.(\d+)\.(\d+)"', text, re.M) |
| 71 | + if match is None: |
| 72 | + raise SystemExit("version line not found in pyproject.toml") |
| 73 | + major, minor, patch = map(int, match.groups()) |
| 74 | + new_version = f"{major}.{minor}.{patch + 1}" |
| 75 | + new_text = re.sub( |
| 76 | + r'^version = "\d+\.\d+\.\d+"', |
| 77 | + f'version = "{new_version}"', |
| 78 | + text, |
| 79 | + count=1, |
| 80 | + flags=re.M, |
| 81 | + ) |
| 82 | + path.write_text(new_text, encoding="utf-8") |
| 83 | + with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh: |
| 84 | + fh.write(f"new_version={new_version}\n") |
| 85 | + PY |
| 86 | + - name: Install build tools |
| 87 | + run: python -m pip install --upgrade pip build twine |
| 88 | + - name: Build package |
| 89 | + run: python -m build |
| 90 | + - name: Publish to PyPI |
| 91 | + env: |
| 92 | + TWINE_USERNAME: __token__ |
| 93 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 94 | + run: python -m twine upload dist/* |
| 95 | + - name: Commit and tag version bump |
| 96 | + run: | |
| 97 | + git config user.name "github-actions[bot]" |
| 98 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 99 | + git add pyproject.toml |
| 100 | + git commit -m "Bump stable version to ${{ steps.bump.outputs.new_version }}" |
| 101 | + git tag "v${{ steps.bump.outputs.new_version }}" |
| 102 | + git push origin HEAD:main |
| 103 | + git push origin "v${{ steps.bump.outputs.new_version }}" |
| 104 | + - name: Create GitHub Release |
| 105 | + env: |
| 106 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + run: | |
| 108 | + gh release create "v${{ steps.bump.outputs.new_version }}" \ |
| 109 | + --title "v${{ steps.bump.outputs.new_version }}" \ |
| 110 | + --generate-notes \ |
| 111 | + --latest \ |
| 112 | + dist/* |
0 commit comments