|
1 | | -name: Create and Publish Release |
| 1 | +name: Publish Python Package |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - 'v*' # Trigger on version tags |
7 | | - branches-ignore: |
8 | | - - '**' # Ignore branch pushes, only trigger on tags |
| 4 | + release: |
| 5 | + types: [created] |
9 | 6 |
|
10 | | -jobs: |
11 | | - publish-pypi: |
12 | | - environment: |
13 | | - name: pypi |
14 | | - runs-on: ubuntu-latest |
15 | | - permissions: |
16 | | - contents: write |
17 | | - packages: write |
18 | | - id-token: write |
| 7 | +permissions: |
| 8 | + contents: read |
19 | 9 |
|
20 | | - steps: |
21 | | - - name: Publish to PyPI |
22 | | - env: |
23 | | - TWINE_USERNAME: __token__ |
24 | | - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
25 | | - run: | |
26 | | - pip install --user uv |
27 | | - uv venv |
28 | | - source .venv/bin/activate |
29 | | - uv pip install build |
30 | | - python -m build |
31 | | - uv pip install twine |
32 | | - twine upload dist/* |
33 | | -
|
34 | | - create-github-release: |
35 | | - environment: |
36 | | - name: pypi |
37 | | - needs: [publish-pypi] |
| 10 | +jobs: |
| 11 | + test: |
38 | 12 | runs-on: ubuntu-latest |
| 13 | + environment: test |
| 14 | + env: |
| 15 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] |
39 | 19 | steps: |
40 | | - - uses: actions/checkout@v3 |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - name: Set up Python ${{ matrix.python-version }} |
| 22 | + uses: actions/setup-python@v5 |
41 | 23 | with: |
42 | | - fetch-depth: 0 |
43 | | - |
44 | | - - name: Create GitHub Release |
45 | | - uses: actions/create-release@v1 |
46 | | - with: |
47 | | - tag_name: ${{ github.ref }} |
48 | | - release_name: Release ${{ github.ref }} |
49 | | - draft: false |
50 | | - prerelease: false |
51 | | - body_path: CHANGELOG.md |
52 | | - env: |
53 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
54 | | - update-stable-and-deploy-branch: |
55 | | - environment: |
56 | | - name: pypi |
57 | | - needs: [create-github-release] |
| 24 | + python-version: ${{ matrix.python-version }} |
| 25 | + cache: pip |
| 26 | + cache-dependency-path: pyproject.toml |
| 27 | + - name: Install dependencies |
| 28 | + run: | |
| 29 | + pip install -e '.[dev]' |
| 30 | + - name: Run tests |
| 31 | + run: | |
| 32 | + python -m pytest |
| 33 | + deploy: |
58 | 34 | runs-on: ubuntu-latest |
| 35 | + needs: [test] |
| 36 | + environment: release |
| 37 | + permissions: |
| 38 | + id-token: write |
59 | 39 | steps: |
60 | | - - uses: actions/checkout@v3 |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + - name: Set up Python |
| 42 | + uses: actions/setup-python@v5 |
61 | 43 | with: |
62 | | - fetch-depth: 0 |
63 | | - - name: Update stable branch |
| 44 | + python-version: "3.13" |
| 45 | + cache: pip |
| 46 | + cache-dependency-path: pyproject.toml |
| 47 | + - name: Install dependencies |
64 | 48 | run: | |
65 | | - git config --global user.name 'GitHub Actions' |
66 | | - git config --global user.email 'actions@github.com' |
67 | | - git checkout stable || git checkout -b stable |
68 | | - git reset --hard ${GITHUB_REF} |
69 | | - git push -f origin stable |
70 | | - git checkout deploy || git checkout -b deploy |
71 | | - git reset --hard ${GITHUB_REF} |
72 | | - git push -f origin deploy |
| 49 | + pip install setuptools wheel build |
| 50 | + - name: Build |
| 51 | + run: | |
| 52 | + python -m build |
| 53 | + - name: Publish |
| 54 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments